Lionel Messi’s heroic hat-trick dragged Argentina back from the brink of an embarrassing World Cup exit with a 3-1 win in Ecuador.

Argentina began the day in sixth position and in danger of not qualifying for a World Cup for the first time since 1970.

Argentina’s victory catapulted them from sixth into the automatic qualification places as they joined Brazil, Uruguay and Colombia in booking their spots in Russia.

They made a terrible start in the high-altitude location of Quito when the hosts went ahead after 38 seconds through Romario Ibarra’s goal – the quickest goal Argentina had ever conceded in a World Cup qualifier.

Argentina, who hadn’t scored in open play for 450 minutes, needed inspiration and it came from a familiar source.

Brazil had already qualified and Luis Suarez scored twice as Uruguay beat Bolivia 4-2 to qualify.

Elsewhere, Peru’s draw against Colombia was enough to secure them a play-off with New Zealand for the final spot, which meant Chile were eliminated after they lost 3-0 in Brazil.