Brazil had to battle to see off Costa Rica at the St Petersburg Stadium and record their first victory of tournament.
Brazil had more of the possession and more of the shots in the first half, with Costa Rica not registering a single shot on target in the first half. But Brazil 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 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.