With Argentina's hopes of qualifying for the World Cup in jeopardy, Lionel Messi scored a hat trick when he was needed most, rallying his country to a 3-1 win over Ecuador and a spot in Russia next summer.

Argentina started the final night of South American qualifying in sixth place, with only the top four qualifying for the World Cup while the fifth goes to an intercontinental playoff against New Zealand.

But the win means Argentina will finish in third, and that books them a place along with Uruguay, Colombia and already-qualified Brazil, while Peru heads to next month's playoff at the expense of Chile, who were eliminated.

Argentina likely needed a win to avoid elimination, but they were behind immediately, as Ecuador scored in the opening minute.

Defender Javier Mascherano tried to head away a long ball forward, but it fell in the path of Ecuador's Romario Ibarra, who played a headed one-two with Roberto Ordonez at the top of the box before scoring past Sergio Romero.

The goal came just 38 seconds into the game, the second-fastest goal in the qualifying campaign, after Willian scored in 35 second for Brazil against Venezuela two years ago.

Argentina were level in the 11th minute as Messi pushed forward and laid the ball off to his left to Angel Di Maria, who returned the pass for the Barcelona star to roll in the equalizer.

Seven minutes later, Messi put his team ahead. Di Maria's pass forward was intercepted, but Messi took it off the defender's boot, ran in on goal and sent a rocket into the top corner.

Messi completed his hat trick with his best of the night in the 62nd minute. After receiving the ball in space about 40 yards from goal, Messi carried the ball to the top of the box, held off a shove from the defender and scooped the ball beyond the keeper's reach and into the net.

Colombia qualified for the World Cup, while Peru reached the playoff after they shared a 1-1 draw.

James Rodriguez put Colombia in front in the 56th minute, and at that point, Peru were facing elimination, but Jose Paolo Guerrero stepped up to score a free kick to equalize and push his team into fifth place.

Peru's draw shattered the World Cup dreams of Chile, who lost 3-0 in Brazil.

After a goalless first half, Brazil took the lead in the 55th minute when Chile goalkeeper Claudio Bravo could only parry Dani Alves' long free kick back into the middle of the box and Paulinho tapped in the rebound.

The lead was doubled two minutes later, when Philippe Coutinho played a long pass forward that landed at the feet of Neymar, who passed across for Gabriel Jesus to score into an empty net.

Manchester City striker Gabriel added a third in stoppage time to seal Chile's fate.

Luis Suarez scored twice to lead Uruguay into the World Cup with a 4-2 win over Bolivia.

Bolivia took a surprise lead through a shocking own goal in the 24th minute. While trying to defend a long thrown-in, Uruguay defender Diego Godin cleared the ball directly into the knee of Gaston Silva, and the ball flew into the net.

But Silva quickly made amends by delivering a pair of assists. Uruguay were level in the 40th minute when Silva set up Martin Caceres to turn the ball in, and two minutes later, he sent in a cross that Edinson Cavani headed over the line.

But the second half belonged to Suarez, who got behind the defense to slot in Uruguay's third in the 60th minute before adding another in the 75th after receiving a pass at the top of the box from Cristian Rodriguez.

Godin was then guilty of another own goal, but Uruguay saw out the win

Paraguay began the night just one point outside of the playoff spot, but they were eliminated with a 1-0 loss at home to Venezuela, who got an 84th-minute goal from Yangel Herrera.