Brazil survived losing Gabriel Jesus to a red card to defeat Chile 1-0 in a thrilling Copa America tie, while Peru edged out Paraguay on penalties after a 3-3 draw.
The host nation will play Peru at Rio de Janeiro’s Nilton Santos stadium on July 5 in the semi-finals.
The other quarter-finals will be played on Saturday, with Argentina playing Ecuador and Uruguay facing Colombia.
Friday’s tie between the last two Copa America champions was more closely fought than their form coming into the game suggested.
Brazil were unbeaten in 11 games and topped Group B, while Chile finished only fourth in Group A and have drawn four of their last six matches 1-1.
After an even and goalless first 45 minutes, the match sparked into life within seconds of the restart, when substitute Lucas Paqueta worked a scrappy one-two with Neymar and then held off Gary Medel to fire home from close range.
However, the outlook changed less than two minutes later. Brazil were reduced to 10 men after Gabriel Jesus was shown a straight red for a horrific kung-fu kick that sent Eugenio Mena tumbling.
Brazil are unused to being under pressure, especially at home, but Chile forced them onto the back foot for large parts of the second half as they poured forward in search of an equaliser.
Ben Brereton, the English-born striker who replaced Alexis Sanchez at half-time, hit the bar with a looping header and Ederson made at least two good saves.
But the Chileans, winners in 2015 and 2016, could not get the goal and crashed out.
Peru beat Paraguay 4-3 on penalties in the most thrilling tournament match so far.
The game had finished 3-3 after a hard-fought match that included red cards to key players of both teams and two goals from Italian-born Gianluca Lapadula for Peru.
The decisive moment came after Peruvian goalkeeper Pedro Gallese denied Alberto Espinola in the shootout. Miguel Trauco then converted his kick to put the 2019 Copa America runners-up back in contention.
Daniel Martinez and Braian Samudio had also missed for Paraguay. Santiago Ormeo and Christian Cueva were kept out by Paraguay’s Antony Silva.
Paraguay opened the scoring in the 11th minute with Gustavo Gomez firing into an empty net from a corner.
Lapadula scored his first of the game in the 21st minute from close range with an assist from former Watford loanee Andre Carrillo.
He added another in the 40th minute with a cross-cum-shot from the left flank after Paraguayan defenders had stopped to complain about a foul.
Peru looked certain they would advance after they took the lead and Paraguayan defender Gomez was sent off in added time for picking up a second yellow card.
But Paraguay started the second half well, and still managed to put pressure on Peru. Junior Alonso levelled the scoring in the 54th minute after firing the ball past Gallese from another corner.
Peru’s Yoshimar Yotun then frustrated their efforts with a goal from the edge of the box 10 minutes from time after the ball deflected off a Paraguayan defender – but still more twists were to come.
Five minutes later, Peruvian striker Andre Carrillo also received his second yellow as the two sides became 10-vs-10.
Paraguay, now throwing everything at Peru, snatched a late close-range goal from substitute Gabriel Avalos, who had come on only eight minutes before, to level the match and send it to penalties.