Farfan struck in the 27th minute and Ramos scored in the 65th to give “Los Incas” their fifth overall World Cup finals appearance and the first in 35 years.
“It’s a big emotion, beyond making history,” tearful Peru midfielder Christian Cueva said. “It’s a child’s dream. We have not broken this bad streak for so long. Now I’m going to celebrate.”
The second-leg match at Lima’s Estadio Nacional was the decider after New Zealand and Peru played to a 0-0 draw in the first leg of their Oceania-South America playoff on Saturday at Wellington.
Peru President Pedro Pablo Kuczynski tweeted his joy after the match, posting the message: “We waited more than 35 years to be in a World Cup again. Thank you warriors for giving us this joy.”
New Zealand, ranked 122nd in the world, was seeking a third World Cup finals berth after appearances in 1982 and 2010.
Peru attacked the “All-Whites” from the start, Incas defender Luis Advincula slamming a left-footed shot off the crossbar in the third minute to delight a full-throated capacity crowd of 40,000.
The opening goal came after Cueva raced down the left wing and flicked a pinpoint center pass with the outside of his right foot to Farfan.
The 33-year-old forward for Lokomotiv Moscow blasted a right-footed shot from the edge of the penalty area past New Zealand goalkeeper Stefan Marinovic and into the back of the net.
In celebrating the goal, Farfan covered his head with the jersey of suspended Peru teammate Paolo Guerrero, unavailable after failing a doping test last month.
“Thanks for the support, Paolo. This is for you,” Farfan said.
After dedicating the match to Guerrero, Farfan gestured to the delighted crowd and said, “Paolo is all around.”
Farfan had another chance in the 42nd minute when Marinovic surrendered a rebound chance, but the sprawled Kiwi made a left-hand save from point blank range and finally clutched the ball to end the threat.
New Zealand’s Kip Colvey gave the Kiwis a dangerous chance in the 50th minute with a centering pass from the right wing to second-half substitute Chris Wood, but the English Premier League striker for Burnley saw his header from six meters denied by Peru goalkeeper Pedro Gallese.
Still vulnerable to a New Zealand away goal, 10th-ranked Peru’s insurance policy came off the foot of Ramos after a corner kick glanced off Farfan’s head.
The ball struck Kiwi defender Winston Reid to land in front of Ramos, who fired it into the goal.
“The people deserve this and much more,” Ramos said. “They supported us when we were bad.”