Philippe Coutinho and Neymar both scored in stoppage time to snatch victory for Brazil after the Paris Saint-Germain forward had been denied a penalty by VAR in a 2-0 World Cup win over Costa Rica.
Desperate for a win in St Petersburg after being held to a 1-1 draw by Switzerland in their opening fixture, Brazil looked like missing out on the three points when the decision to award Neymar a spot-kick was overturned in the 79th minute.
The former Barcelona star went down softly under the challenge of Giancarlo Gonzalez, with referee Bjorn Kuipers initially pointing to the spot.
However, VAR intervention led to a reversal of the decision, as replays showed minimal contact between Gonzalez and Neymar, who had fallen backwards as if pulled down.
The incident came late in a match Brazil dominated but in which for long spells they struggled to break down a determined Costa Rica defence.
However, with the clock having ticked past 90 minutes, Coutinho and Neymar stepped forward to break Costa Rican hearts and spare Brazilian blushes, sending their side top of Group E ahead of the clash between Serbia and Switzerland.
Neymar dropped to his knees in tears on the final whistle after the tournament's most successful side came through a real test of character against a Costa Rica side whose hopes of progression are now over.
Costa Rica – rightly anticipating that Brazil would enjoy the lion's share of possession – sat deep but looked dangerous when they were given the rare opportunity to counter.
Celso Borges should have done better when he dragged an effort wide of the target from a Cristian Gamboa cutback after 13 minutes and, for all of their time on the ball, Brazil found it difficult to find a way through the Costa Rica defence.
Gabriel Jesus hammered a shot into the back of the net from an offside position in the 25th minute, rightly prompting a flag from the linesman, but the incident sparked a period of Brazil pressure, with Marcelo and Coutinho trying their luck from distance and a Neymar cross necessitating a desperate defensive header over the crossbar.
Marcelo had looked most likely to make something happen for Brazil but found Keylor Navas equal to his low drive five minutes from the break, the Real Madrid goalkeeper stooping to halt the game's first shot on target from his clubmate.
Neymar – named in the starting XI despite struggling with an ankle injury this week - confronted the referee on the pitch and in the tunnel at half-time, presumably taking objection to Costa Rica's rough-and-ready approach to dealing with him.
And Brazil returned to the field with added purpose after the break, with Jesus heading against the crossbar before Navas diverted Coutinho's follow-up wide.
Navas – a growing thorn in Brazil's side – pulled off even greater heroics to deny Neymar with a fingertip save soon after, while another Coutinho strike was directed straight at the goalkeeper.
Neymar curled around the right-hand post from 18 yards after the defence opened up for him in the 72nd minute, before the officials arrived at the correct decision via VAR to deny him a penalty.
That incident threatened to dominate the headlines until Coutinho prodded Brazil in front in the 91st minute, getting on the end of a Roberto Firmino nod down and a helpful touch from Jesus.
And Neymar was on hand to tap home Douglas Costa's delicate chipped cross even deeper into stoppage time to wrap up three points that had appeared like slipping through Brazilian fingers.
The relief was clear as the tears rolled down the face of the world's most expensive player, who surpassed Romario in third on the country's all-time list of goalscorers.
Key Opta stats:
- This was Brazil's first World Cup victory thanks to a goal scored in the 90th minute.
- Brazil have won 10 of their 11 meetings with Costa Rica in all competitions, losing the other in a friendly in 1960.
- Costa Rica are winless in their last five World Cup matches (D3 L2).
- Costa Rica had just three shots in this match, with all of those coming in the opening 15 minutes.
- Brazil's second goal was timed at 96:49 – the latest recorded 90th minute goal in a World Cup match since 1966.
- In all international matches, Brazil are unbeaten in 13 games (W9 D4 L0), conceding just three goals in that run.
- Neymar has been fouled 14 times so far in the 2018 World Cup, more than any other player.
- Neymar has scored 56 goals in 87 matches for Brazil – only Pele (77) and Ronaldo (62) have scored more.
|Ibrahimovic to watch England at Wembley – Zlatan will honour Beckham bet|
|Cubs use five-run fifth inning to trump Cardinals|
|Manchester United 1 America 1: Mata salvages draw for Red Devils|
|Steelers´ Super Bowl window getting smaller - Brown|
|Neymar cares about PSG and will stay amid Real Madrid speculation|
|NFL, NFLPA at ´standstill agreement´ over anthem policy|
|Guardiola: It would´ve been a mistake for Jorginho to join City|
|Angels star Ohtani cleared to resume pitching|
|´I don´t give a f***´ – Cousins hits back at critics after Warriors move|
|Merritt leads Barbasol Championship|
|Ruud awakening for Ferrer in Bastad|
|Nibali withdraws from Tour de France with back fracture|
|Fabinho: I´ll try to convince Mbappe to join Liverpool|
|Beating Messi boosted France´s World Cup belief – Lloris|
|Carnoustie saving the worst until last|
|McIlroy´s youthful exuberance could be a bad sign for Carnoustie contenders|
|Saints triumph at second-placed Wigan|
|Anfield atmosphere sweetened Alisson on Liverpool|
|Bouchard reaches Gstaad quarter-finals|
|´What are you waiting for?´ - Alisson reveals Salah text messages|
|´Full package´ Alisson could not be missed - Klopp|
|Alisson to Liverpool: Brazil star becomes most expensive goalkeeper in history|
|Alisson to Liverpool: Brazilian´s stats blitz Mignolet, Karius|
|Liverpool sign Alisson in world-record deal|
|The Open 2018 diary: Spieth´s got ball skills as Finau proves the scratch golfer|
|Woods: Score doesn´t reflect how well I played|
|Can we go to Paris now? - Thomas in a hurry after conquering Alpe d´Huez|
|Thomas: I could have finished stronger|
|Kisner shines at baked Carnoustie as McIlroy, Rahm and Thomas loom|
|Sarri´s mentality made me a better footballer - Jorginho|
|Tax rates played a role in Ronaldo joining Juventus, says LaLiga president|
|Aggressive McIlroy doing it his way, not the fairway|
|I let him have it - Spinazzola ribs Ronaldo over Juve shirt number|
|Thomas makes it back-to-back wins|
|Ramos may remain for Spain but Luis Enrique promising surprises|
|Cazorla still playing through pain after Villarreal appearance|
|Vegas to Carnoustie - a hellish trip for Jhonattan|
|NFL training camp 2018: Five under-the-radar rookies to watch|
|Woods off to a flyer as Thomas charges|
|Sanchez given green light to join Man Utd tour|
|Greipel, Groenewegen and Gaviria latest sprinters to abandon Tour de France|
|Luis Enrique hopeful over Pique as he plots a Spanish evolution|
|I had a brain fart - Spieth disappointed with missed opportunity|
|I´ve sacrificed too much to quit, says injury-plagued Rossi|
|Klopp rejects Henderson´s plea to return early to Liverpool training|
|Open champion Spieth loses ground in scrappy finish|
|Alexis Sanchez hints visa issue sorted as United States trip beckons|
|Kovac an admirer of Pavard, expects James to stay|
|Dzeko happy at Roma and eyeing silverware|
|Eels win basement battle with Bulldogs|
|Kluivert to follow Totti´s example after taking ´big step´ with Roma|
|Kisner hopes to return Claret Jug favour to Spieth|
|FIBA bans 13 players & two coaches over Philippines-Australia brawl|
|Spieth and Rahm in the mix as Kisner sets the target|
|Monchi insists Roma remain ambitious as Liverpool close in on Alisson|
|Cavendish thanks ´race that shaped career & heart´ after cruel Tour exit|
|No Trent Bridge Ashes Test as England confirm schedule|
|Ajax tell Barcelona not even ´insane´ money will buy De Ligt, De Jong|
|Hamilton agrees two-year Mercedes extension|
|Uran withdraws from Tour after failing to shake off injuries|
|Spieth tees off Open defence|
|Zidane has shown no will to coach France, insists FFF president|
|Risking the curse - Steelers star Brown lands on Madden 19 cover|
|Pogba silenced his critics with World Cup displays – Ibrahimovic|
|Warburton overwhelmed by support following retirement|
|Wilshere excited by tactics of Wenger-like Pellegrini|
|Deschamps never considered France exit prior to World Cup win|
|Persepolis eye Champions League after Iran impress at World Cup|
|Sandy Lyle gets The Open underway at Carnoustie|
|Roosters sign England international Hall|