Lionel Messi fired Argentina into the World Cup with a brilliant hat-trick in a 3-1 win over Ecuador in Quito that drew a line under a chaotic campaign that had left the two-time champions in danger of failing to qualify.

The Barcelona superstar scored twice inside the opening 20 minutes to give Argentina the lead after Ecuador had stunned the visitors with an opening goal after from Romario Ibarra after 38 seconds.

Messi then completed his hat-trick – the 44th of his dazzling career – with a sublime chip in the second half to seal the victory.

Argentina had started the day outside the automatic qualifying positions, needing to secure their first win in Quito since 2001 to be certain of claiming at least a playoff place.

It looked as if Argentina’s worst fears were set to become a reality after Ibarra’s opening goal in the first minute.

But it was not long before Messi stamped his authority on the game, hauling his team back into the contest with a composed opening goal.

The equaliser came in the 12th minute when Messi darted forward and quickly released Angel Di Maria down the left.

The Paris Saint-Germain attacker duly returned the favour as Messi raced into the penalty area to poke home a low finish past Maximo Banguera.

Eight minutes later Messi fired Argentina into the lead with another virtuoso strike, lashing into the top corner.

Messi then completed his hat-trick with a sublime chip in the 62nd minute to make it 3-1.

Watch all three goals here

With inputs from AFP