Neymar, David Luiz and Marcelo scored in the shootout, and Brazil goalkeeper Julio Cesar saved two penalties before watching Gonzalo Jara’s final attempt hit the post.
Brazil, which extended its 39-year unbeaten streak in home competitive matches to 61, will face Colombia in the quarterfinals.
Neither team managed to score at the Mineirao Stadium after first-half goals from Luiz and Sanchez, but Brazil came close to an early exit when Mauricio Pinilla’s shot hit the crossbar in the final moments of extra time.
Chile also had the best chance in the second half, when Cesar’s spectacular save on Charles Aranguiz’s shot kept the score even.
Brazil has reached the quarterfinals of each World Cup since Argentina eliminated it in the second round in 1990. Getting knocked out at that stage in its own World Cup would have been a disaster.
But the Brazilians overcame their nerves in the shootout, with Neymar scoring the final penalty after Cesar stopped spot kicks from Pinilla and Sanchez.
When Jara hit the post, some of Brazil’s players celebrated wildly while others fell to the ground, exhausted and emotionally drained. Willian, who missed a penalty for Brazil, sobbed uncontrollably, as Fred helped him to his feet.
n Colombia 2, Uruguay 0: James Rodriguez scored twice to put Colombia into the World Cup quarterfinals for the first time.
Rodriguez gave his team the lead with a stunning long-range volley in the 28th minute and added the second from close range shortly after the break as Colombia dominated a Uruguay side that sorely missed banned striker Luis Suarez.
Rodriguez now has a tournament-leading five goals in Brazil and further enhanced his status as perhaps the tournament’s biggest revelation.
Uruguay, meanwhile, struggled badly without Suarez, and his replacement Diego Forlan was substituted in the 53rd after a disappointing performance in what was probably his final World Cup appearance.