Brazil had to battle to see off Costa Rica at the St Petersburg Stadium and record their first victory of this World Cup, winning 2-0 with goals in added time from Philippe Coutinho and Neymar.
After their opening 1-1 draw with Switzerland, the result lifts Brazil up to four points, while Costa Rica are out of the World Cup, having lost their opening Group E match 1-0 to Serbia.
Brazil had more of the possession and more of the shots in the first half but they could not turn their dominance into goals. Gabriel Jesus had the ball in the net after 26 minutes but it was correctly ruled out for offside.
Both Philippe Coutinho and Marcelo had long-range shots that whizzed off target, while Celso Borges shot wide from eight yards out for Costa Rica when he should really have done better.
Both sides had chances in the second half but it looked as if a spot-kick might settle it. Brazil thought they had a penalty with 12 minutes left, when Björn Kuipers pointed to the spot after Neymar fell theatrically following a brief tangle with Giancarlo González.
But after consulting VAR, Kuipers deemed that there had been no meaningful contact and reversed his decision. Shortly afterwards both Neymar and Coutinho were booked for dissent.
The deadlock was finally broken in the first minute of added time, when Coutinho smashed home from close range after the substitute Roberto Firmino headed a cross back into the middle and Jesus toe-poked the ball away from a defender. It was Coutinho’s second goal of the World Cup.
Neymar was then played in by Douglas Costa to volley into an empty net from a few yards out in the dying seconds.
Serbia are playing Switzerland at the Kaliningrad Stadium in Friday’s late game. Group E concludes on Wednesday, with Serbia playing Brazil in the Spartak Stadium in Moscow while Switzerland play Costa Rica in Nizhny Novgorod.