Peru will play either Australia or the United Arab Emirates in June following a 2-0 victory over Paraguay that meant Colombia and Chile miss out.
Brazil, Argentina, Ecuador and Uruguay had already qualified for the Qatar tournament in November.
Colombia missed out by one point, in sixth, after beating Venezuela 1-0.
Chile also needed to win and hope that Peru and Colombia both dropped points to stand a chance of qualification - but they lost 2-0 to Uruguay after fine goals by Atletico Madrid's Luis Suarez and Real Madrid's Federico Valverde.
Peru are seeking consecutive World Cup appearances, having defeated New Zealand 2-0 over two legs to reach the 2018 tournament in Russia.
They will will meet Australia or the UAE in the intercontinental play-off, after both countries were third in their respective Asian qualifying groups.
Australia, who had already secured a play-off place, lost 1-0 to Group B winners Saudi Arabia on Tuesday, while the UAE denied South Korea top spot in Group A with a 1-0 win that ensured their play-off place ahead of Iraq.
Unbeaten Brazil, who have one rearranged match against Argentina still to play, have 45 points from 14 wins and three draws - two more than Marcelo Bielsa's Argentina achieved in 2002.
Everton's Richarlison struck twice for Tite's side and Newcastle United's January signing Bruno Guimaraes also scored, following Lyon's Lucas Paqueta's opener.
It was a third successive 4-0 victory for Brazil, despite being without suspended Paris St-Germain forward Neymar.
Meanwhile, second-placed Argentina extended their unbeaten run to 31 games in a 1-1 draw away to Ecuador, who qualified in fourth following Uruguay's win.
Peru ended a 36-year wait for a World Cup finals appearance in 2018