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.
|Thunder´s Westbrook: ´When we defend like that — best team in the league´|
|Kante at his best further forward, reiterates Sarri|
|Rose capitulates in Indonesia to squander chance to top rankings|
|Fielding: The better man won but I lived a dream|
|Rallying Bulls stun Spurs, LeBron and Ball post triple-doubles|
|Latham century puts New Zealand in commanding position|
|Mayfield leads Browns past Broncos|
|Canelo-GGG trilogy? We can make it happen – Alvarez|
|Canelo outclasses Fielding by third-round TKO|
|Farmer retains title prior to Canelo-Fielding bout|
|Qatar unveils Lusail Stadium for 2022 World Cup|
|Lakers pair LeBron, Ball revel in triple-double feat|
|Allegri hails ´great professional´ Ronaldo|
|LeBron, Ball first Lakers team-mates with triple-doubles in same game since 1982|
|Premier League contenders Liverpool ready to win titles – Henderson|
|Hopkins´ two TDs help Texans close in on AFC South title with win over Jets|
|Courtois: Simeone criticises Real Madrid to boost popularity|
|Mourinho in the dark over transfers as Pogba rumours swirl again|
|Mourinho marvels at Salah going nuclear|
|The lucky ones - Mourinho assesses Liverpool´s title charge|
|Juventus boss Allegri turned his back on Ronaldo penalty|
|Dickerson hoping Barkley falls short of breaking his records|
|Bristol shock La Rochelle, Clermont win again|
|LeBron: Meeting Jordan for first time was godly|
|Ronaldo scores Juventus´ 5,000th Serie A goal|
|I was all over the place - Allen reaches Scottish Open final despite hangovers|
|Solari defends wasteful Asensio after slim Madrid win|
|Torino 0 Juventus 1: Ronaldo capitalises on Zaza woe|
|I do my work on the pitch – Icardi unconcerned by Inter contract discussions|
|Lyon defender Rafael set for three months out|
|Inter captain Icardi is the ´perfect´ striker – Spalletti|
|Fulham have to stick together, says Ranieri|
|Nuno hails ´very special´ Wolves achievement after third straight win|
|Stuttgart captain Gentner´s father dies at Hertha fixture|
|Valverde not desperate for new centre-back amid talk of Christensen loan|
|Toulouse and Saracens stay perfect in Champions Cup|
|Kovac lauds Bayern´s best performance of the season|
|Barcelona can get the best out of Coutinho and Dembele, claims Valverde|
|Borussia Dortmund 2 Werder Bremen 1: Alcacer and Reus guarantee top spot for mid-season break|
|Bristol City 2 Norwich City 2: Canaries knocked off their perch despite late equaliser|
|Atletico´s fighting spirit lauded by Simeone, Godin|
|Hodgson relieved to see Palace end Zaha curse|
|Real Madrid 1 Rayo Vallecano 0: Benzema secures steady response to CSKA loss|
|Fulham 0 West Ham 2: Snodgrass, Antonio punish profligate hosts|
|Warnock brands refereeing situation ´a disgrace´ after Watford defeat|
|Inter 1 Udinese 0: Icardi penalty gets lethargic Nerazzurri back on track|
|Wagner retains belief in survival bid despite Newcastle defeat|
|Griezmann feeling the strain after busy 2018|
|Pochettino ´so pleased´ as tired Tottenham scrap to Burnley win|
|Man Utd hand Smalling new contract|
|ES Tunis 0 Al Ain 3: Convincing victory books River Plate semi|
|Championship Review: Bamford fires Leeds to summit, Middlesbrough defeated by QPR|
|Curry reacts to Kings´ trolling with moon landing video|
|Wentz ruled out of Rams clash|
|Pochettino reaches 100 Premier League wins for Tottenham faster than Wenger for Arsenal|
|Real Valladolid 2 Atletico Madrid 3: Griezmann the hero on landmark appearance|
|Silva rues Richarlison´s missed chances at City|
|Gibson has no worries over Proteas batsmen|
|Wolves 2 Bournemouth 0: Jimenez and Cavaleiro score against toothless Cherries|
|Crystal Palace 1 Leicester City 0: Captain Milivojevic earns vital victory|
|Watford 3 Cardiff City 2: Hornets hang on despite late fightback|
|Tottenham 1 Burnley 0: Eriksen snatches victory at the death|
|Huddersfield Town 0 Newcastle United 1: Rondon strike settles scrap|
|Sabres suspend forward Berglund for failing to report to the team|
|Saunders thanks Fury for getting him ´back on the right track´|
|Hannover 0 Bayern Munich 4: Gnabry and Kimmich star in crushing win|
|I admire Sterling – Guardiola|
|City´s strength in depth makes it hard for me – Jesus|
|Jamieson holds slender lead in Malelane|
|Kashima Antlers 3 Guadalajara 2: Comeback win sets up Real Madrid semi-final|