Neymar broke down in tears, Brazil breathed a sigh of relief and their coach Tite pulled a muscle as he celebrated a last-gasp 2-0 win over Costa Rica on Friday.
Philippe Coutinho finally broke a dogged Costa Rica's resistance in the 91st minute before Neymar added a second in the 96th to propel the five-time champions towards the World Cup last 16.
At the final whistle, Neymar sat down on the grass and wept, with the emotion of victory hitting home after a tense Group E contest at the Saint Petersburg Stadium.
Tite, meanwhile, was left limping, after the 57-year-old reacted to Coutinho's strike by bursting onto the pitch and tripping over his own feet.
"I think I kind of pulled a muscle!" Tite said. "I'm limping now after the celebration. We were a bit over-excited."
Costa Rica looked likely to hold on for a hard-earned draw, particularly after Neymar had a penalty award chalked off by referee Bjorn Kuipers, following a consultation with the Video Assistant Referee.
This was only Neymar's fourth outing since returning from three and a half months out with a foot injury and Tite admitted his star player will need time to hit top form.
"He is resuming a process," Tite said. "He played the full match. He is a human being, he needs some time to resume his high standard. Before then, there is a team that has to be strong and not depend on him."
Brazil will now head into their final group game against Serbia next week confident of reaching the knock-out stages, with four points collected from their opening two matches.
Costa Rica, meanwhile, are out but the Central Americans were far from disgraced here.
"I don't know what else we could have done," their coach Oscar Ramirez said.
"Considering what I have at my disposal and what they have, I think it is reasonable what we did."
Neymar started despite limping out of training on Tuesday with a hurt ankle, which the Brazilian FA said was sustained as a result of snapping Swiss defenders.
He faced the most devoted of markers in Costa Rica's Cristian Gamboa, the Brazilian spending most of the half hopping over scything tackles or dodging past a barging shoulder.
After a slightly ponderous first half, Brazil cranked up the pressure in the second as Gabriel Jesus's header crashed against the crossbar and Coutinho was denied by the ever-present Gamboa on the line.
There was more drama to come. With just over 10 minutes left, Neymar's sharp turn prompted Giancarlo Gonzalez to lose his footing and put his arm across the striker's chest.
Frustration brewed but Costa Rica's resistance was finally ended in stoppage-time as Marcelo's deep cross was kept alive by Roberto Firmino and a loose touch by Jesus dribbled perfectly into Coutinho's path. Six yards out, he sidefooted home.
Broken, Costa Rica conceded again right at the death. Firmino drove through the middle before Douglas Costa squared for Neymar finally to find the net.