The 19-year-old forward scored his eighth goal in 14 matches for Brazil from close range, converting substitute Daniel Alves's cross in the 60th minute. Neymar also hit the crossbar with a shot from outside the box in 72th minute, just before being replaced by Hulk.
Costa Rica finished the match with 10 players after Heiner Mora was shown a straight red card six minutes from time for a foul on substitute forward Jonas.
"It was a very difficult game. Costa Rica are no fools but our national team knew how to handle the pressure and were able to win," Neymar told reporters at San Jose's Nacional stadium.
Manchester United defender Fabio made his debut for Brazil playing at right-back but left the field 10 minutes after the break due to an injury and was replaced by Alves.
Brazil play at Mexico on Tuesday.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.