Brazil survived losing Gabriel Jesus to a red card early in the second half to beat Chile 1-0 in a thrilling Copa America tie to move into the competition's semi-finals.
The hosts will play Peru, who beat Paraguay on penalties earlier in the day, at Rio de Janeiro's Nilton Santos stadium on July 5 for a place in the final.
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.
"We were beaten by the favourites, the team playing at home," said Chilean midfielder Arturo Vidal. "At least we will leave with our heads held high."
Peru advanced earlier after beating Paraguay 4-3 on penalties, the match ending in an exciting 3-3 draw with red cards to key players of both teams and two goals by Italian-born Gianluca Lapadula for Peru.
The decisive moment in the match came after Peruvian goalkeeper Pedro Gallese stopped Alberto Espinola in the shootout.
Daniel Martinez and Braian Samudio had also missed for Paraguay. Santiago Ormeno and Christian Cueva were blocked by Paraguay's Antony Silva.
"This was an amazing match," a tired Lapadula said after the shootout, in which he converted from the spot.
"We can't choose adversaries, we have to think we are in the semi-final. Now we have to work to get there well."