Brazil 1-1 Chile: Hosts win 3-2 in dramatic penalty shootout
The hosts took the lead through David Luiz's first goal for his country. Neymar's corner was flicked on by Thiago Silva and Luiz redirected the ball into the net with his knee.
But Chile equalised when Hulk lost the ball to Eduardo Vargas, who fed Alexis Sanchez and the Barcelona man delivered a precise finish into the bottom left corner.
In the second half, Hulk had a goal disallowed and received a booking after the assistant referee adjudged the Zenit St Petersburg player to have controlled the ball with his right arm.
Brazil's second booking was picked up by Luiz Gustavo and it rules him out of the quarter final.
Brazil continued to create plenty of chances but did not have the cutting edge needed to dispatch Chile. Fred could not pick up where he left off with his goal against Cameroon and his replacement, Jô, was similarly toothless in attack.
The hosts could have been punished for not taking their chances when, in extra time, Chile substitute Mauricio Pinilla crashed a shot against the crossbar from the edge of the box after beating Thiago Silva.
When the game went to penalties, Brazil goalkeeper Júlio César quickly made himself a hero, with fine saves from Pinilla and Sanchez.
But a nervous-looking Willian dragged his penalty past the left post and Hulk hit his down the middle, Claudio Bravo saving with his feet.
When Marcelo Díaz scored Chile's fourth to level it all up, a nervous silence spread around Mineirão.
The poster boy of the World Cup, Neymar, then stepped up and didn't let his country down with his cool finish.
Chile's Gonzalo Jara struck the right post with his effort, sending his side out, and Brazilians into delirious celebrations.