Neymar in dive storm
Brazil won the battle but Neymar lost to VAR on a day of controversy for the South American star at the World Cup.
The tournament favourites needed a pair of injury-time goals to eventually break down Costa Rica with Philippe Coutinho on target before Neymar added the insurance goal.
But Brazil's win was overshadowed by a petulant and theatric display from the PSG striker who was awarded a penalty with 15 minutes remaining before the decision was reversed when replays showed he had dived. Referee Bjorn Kuipers reverted to VAR and acknowledged that his initial decision was incorrect.
Neymar escaped a booking for simulation, and played his part in Brazil's late victory. At full-time, the 26-year-old broke down in tears on the pitch as he digested a game that was something of an emotional rollercoaster.World Cup player watch: Tears of joy overcome Neymar
Brazil coach Tite stood up for his leading player afterwards, claiming that the penalty should have stood.
"If I was the referee I would not go back but I respect that because it is subject to interpretation," he said.
"We don't need referees to win the game, we just want it to be fair. To me, it was a penalty. But we don't want any help. We don't need any help, the players don't need help, I don't want help. We want to be more competent."
He suggested that pressure should be taken off the shoulders of Neymar who arrived in Russia off the back of an injury-interrupted end to his club campaign.
"You can't put all the responsibility on one player," he said. "He was out three-and-a-half months and he played the full match. He's a human being. He needs some time to resume his high standard but before he does that there is a team which has to be strong and not dependent on him."
Meanwhile, Argentina could yet be handed a World Cup reprieve after Nigeria's 2-0 win over Iceland threw the race for second place in Group D wide open.
Croatia will go through as group winners and are likely to field a second-string side against Iceland. But Argentina now know that if they succeed in beating Nigeria in their final game, they will go through if their winning margin is bigger than any Icelandic win over the Croats.
If Iceland fail to beat an understrength Croatia, Lionel Messi's side will go through to the last 16 if they can prevail against the Nigerians.