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.
New Zealand, ranked 122nd in the world, was seeking a third World Cup finals berth after appearances in 1982 and 2010.
Also Read
"I'm proud of the team, but everybody should be proud of these players because what they've done is incredible and tonight they played to an incredible level," New Zealand manager Anthony Hudson said.
"Overall, very proud, given the challenges we had coming here, with the key players we had who were injured, knowing that we had to manage game time for many of them."
"We would have had a better chance of winning this game if our hotel had been right next to Peru's national team. And we'd have had some more sleep. Next time we'll stay next to Peru's hotel," Hudson said.
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.
- Win dedicated to Guerrero -
=============================
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.
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.
Disclaimer: No Business Standard Journalist was involved in creation of this content