Tite's World Cup favourites left it late to see off a determined Costa Rica side in St Petersburg.
The five-time winners lacked attacking thrust and spent much of their second game in Russa frustrated by their Central American opponents, for whom Keylor Navas was impeccable.
Oscar Ramirez's side were quarter-finalists four years ago and remain defensively sound.
For 90 minutes they held Neymar and co. at arm's length.
However, in injury time, their resistance was finally broken by Philippe Coutinho.
The clock had ticked past 90 minutes when Marcelo crossed from the left and substitute Roberto Firmino headed the ball back across goal to Gabriel Jesus.
Jesus's first touch took the ball away from the defender and Coutinho raced in to poke past Keylor Navas from six metres out and claim his second goal of the tournament.
Neymar added the second with practically the last kick of the game, racing on to Jesus's square ball following a quick counter-attack as Costa Rica were forced to push for the equaliser.
The forward, who thought he had won a penalty in the 77th minute only for the referee to reverse the decision after consultation with the video assistant referee (VAR), was overcome by emotion on the whistle, covering his face as tears streamed down his cheeks.
For long periods during the 90' however, he had been on the periphery.
Follow all the action, as it happened, below.
Brazil XI: Alisson; Fagner, Thiago Silva, Miranda, Marcelo; Paulinho, Casemiro, PCoutinho; Willian, Gabriel Jesus, Neymar.
Costa Rica XI: Navas; Duarte, Gonzalez, Acosta; Gamboa, Borges, Guzman, Oviedo; Ruiz, Urena, Venegas.