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. (Match in pics)
"My teammates are giving me a lot of strength on the field so I give my best," Julio Cesar said. "We're just three steps away and I hope to give another interview with Brazil partying." (Match in pics)
Brazil will next face either Colombia or Uruguay in the quarterfinals. (Update: Colombia defeat Uruguay, will now face Brazil)
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 Julio 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 Julio 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.
As the crowd roared, the Brazilian players joined hands in a human chain. The Chileans stood still, wiping the sweat off their faces.
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 Chile defender Gonzalo 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 Brazil's 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.
Neymar, Fred and Dani Alves had chances in the first half while a second-half goal from Hulk was disallowed when referee Howard Webb ruled he handled the ball.