BELO HORIZONTE, Brazil (AP) Tight and tense as it was, it was enough to keep Brazil's national obsession of winning the World Cup on home soil from taking a desperately disappointing turn.
And it wasn't Neymar, the country's poster boy for this year's World Cup, that played the key role this time. It was goalkeeper Julio Cesar, the country's scapegoat from the last World Cup, who made several crucial saves and even got some help from the woodwork in a 3-2 penalty shootout win over Chile.
With the score level at 1-1 on Saturday, Brazil was inches away from an early exit when Chile forward Mauricio Pinilla hit the crossbar in the final moments of extra time.
Then, on the final kick of the match and after a pair of saves from Cesar in the shootout, Gonzalo Jara hit the post.
''I believe the Brazilian people just needed this,'' said Cesar, who made a mistake four years ago in South Africa that led to a quarterfinal loss. ''The players, everybody else, we needed this.''
The fans still have to wait to celebrate the title, however. There are three more matches to win before the home team can lay claim to a sixth World Cup title.
''Let's see if we can make fewer mistakes in the next matches,'' Brazil coach Felipe Scolari said. ''Perhaps next time we won't be as lucky.''
To be fair, it wasn't just luck that saw Brazil through to the quarterfinals at Mineirao Stadium, which was a sea of Brazilian yellow with islands of Chilean red.
Neymar, David Luiz and Marcelo scored in the shootout, and Cesar saved penalties from Pinilla and Alexis Sanchez before watching Jara's final attempt hit the post.
The game over, some Brazilian players fell to the ground, exhausted and emotionally drained. Willian, who missed a penalty for Brazil, sobbed uncontrollably, as Fred helped him to his feet.
The Chileans stood still, staring into the ground, wiping the sweat off their faces.
''Do you think I can be satisfied with the result?'' Chile coach Jorge Sampaoli said. ''We've played a hard 120 minutes even if everybody was against us in the stadium.''
Brazil, which extended its 39-year unbeaten streak in home competitive matches to 61, will next face either Colombia or Uruguay in the quarterfinals.
Brazil dominated the first half against Chile and took the lead when Luiz scored following a corner kick. After Sanchez equalized for Chile, Brazil had several chances to regain the lead.
Neymar's header deflected wide, Fred lifted the ball over the bar from close range and Dani Alves forced a backpedaling Claudio Bravo to make a one-hand save.
But after referee Howard Webb disallowed Hulk's second-half goal, ruling he had used his arm to control a long pass, Brazil lost the initiative to a Chile team that can leave the World Cup with pride after eliminating defending champion Spain in the group stage.
Pressing deep inside Brazil's half, Chile pressured the home side into making mistakes or resorting to long passes to Hulk and Neymar.
And, again, it was Cesar that often came up big, making a spectacular save on Charles Aranguiz's shot to keep Chile from taking the lead in the second half.
''We tried to give everything, we tried to fight for a dream, and we didn't achieve it,'' Chile midfielder Arturo Vidal said. ''But we gave all our effort on the pitch.''
Chile has never defeated Brazil in Brazil and hasn't reached the World Cup quarterfinals since 1962, when it hosted the tournament.
Brazil, meanwhile, has reached the quarterfinals of each World Cup since Argentina eliminated it in the second round in 1990.
Brazil went ahead in the 18th minute after Thiago Silva deflected Neymar's corner kick toward the far post. Luiz was given the goal but replays showed Jara may have touched the ball before it went in.
Brazil lost the lead when it failed to cope with Chile's aggressive pressure in a throw-in situation deep inside its half of the field. Eduardo Vargas intercepted Hulk's pass and found Sanchez on the right side of the area. The Barcelona striker scored easily with a shot toward the far post.
In the end, however, it was Brazil moving on to the quarterfinals, with the hopes of a nation planted on the backs of every player.
''I hope these are lessons being given to the whole population,'' Scolari said. ''If you make a promise, you must deliver. This is what the players are doing.''
Brazil: Julio Cesar; Dani Alves, Thiago Silva, David Luiz, Marcelo; Luiz Gustavo, Fernandinho (Ramires, 72), Oscar (Willian, 106); Hulk, Fred (Jo, 64), Neymar.
Chile: Claudio Bravo; Mauricio Isla, Gary Medel (Jose Rojas, 108), Eugenio Mena, Francisco Silva, Gonzalo Jara; Arturo Vidal (Mauricio Pinilla, 87), Marcelo Diaz, Charles Aranguiz; Alexis Sanchez, Eduardo Vargas (Felipe Gutierrez, 57).