Peru will face the All Whites in Wellington in November.
The final round of South American qualifying matches was played on Wednesday afternoon (NZT), with five games across the continent.
With New Zealand to face the fifth placed South American team in the inter-continental playoffs next month, it was a crazy day for permutations, and New Zealand's possible opponent changed on five different occasions.
At the end it was the Peruvians who prevailed, and they could reach their first World Cup since 1982.
World No 12 Peru started the day in fifth, but Colombia had moved into the spot by halftime in all the games, as Argentina led Ecuador to jump into third.
That meant Peru fell from fifth to sixth, and Colombia from fourth to fifth.
But the changes kept coming across the second half. Chile dropped to fifth after conceding against Brazil. Peru briefly occupied the spot for a few minutes, before they conceded against Colombia which sent Chile back up to fifth. But Peru equalized in the 74th minute which proved pivotal, and they hung on to advance on goal difference.
The crucial game in Quito between Ecuador and Argentina had a dramatic start, when Ecuador scored after just 39 seconds.
However Argentina quickly recovered, with Messi equalizing in the 11th minute, after a combination with Angel Di Maria.
The Barcelona star then lashed home from 10 yards six minutes later to calm Argentinean nerves and Messi wrapped up his hat trick in the second half to seal their place in Russia.
Meanwhile Chile crashed to a 3-0 defeat to end their hopes, which allowed Peru to advance ahead of their Andean neighbours on goal difference.
Ecuador 1 Argentina 3
Uruguay 4 Bolivia 2
Brazil 3 Chile 0
Peru 1 Colombia 1
Paraguay 1 Venezuela 1
How the opponent was found:
12:30pm The five matches kick off across South America. Peru sits in fifth position.
12:50pm Lionel Messi's second goal takes Argentina into the lead against Ecuador. Colombia move into fifth.
1:41pm. Brazil takes the lead against Chile. Chile move into fifth.
1.46pm. Brazil extends their lead. Peru move into fifth on goal difference.
1.47pm. Colombia takes the lead against Peru. Chile go back into fifth.
2.08pm Peru equalize against Colombia. Peru move back up to fifth.