It all seemed lost until the dying minutes when Costa Rica's Los Ticos stunned Japan 1-0 thanks to Keysher Fuller's late goal on Sunday which blew Group E wide open and handed Germany a chance to salvage some pride.
Japan, who shocked four-time champions Germany 2-1 in their opener in Qatar, could have taken a giant stride toward the last 16 with a win.
Instead, they labored for large parts of the match against a Costa Rica side who were hammered 7-0 by Spain, then defender Keysher Fuller scored in the 81st minute with a deflected strike.
It was Costa Rica's first shot on target at this World Cup and could be of huge benefit to the Germans.
The result left Spain, Japan, and Costa Rica all on three points. Spain face Germany later Sunday in another crucial contest.
Japan made five changes to the team which shocked Germany in their opening match as coach Hajime Moriyasu made full use of his 26-man squad.
In temperatures of 32 degrees Celsius at Ahmad Bin Ali Stadium, Japan immediately went on the attack and won a corner within 30 seconds to signal their intent.
Costa Rica coach Luis Fernando Suarez had resisted making wholesale changes to the team thumped by Spain, dropping teenage winger Jewison Bennette and defender Carlos Martinez to the bench.
Gerson Torres and 34-year-old center-back Kendall Waston took their place in an aging XI that featured four players from the 2014 World Cup quarter-finals.
But Japan's early promise melted in the Doha sun and the first shot at goal – a tame effort that sailed high and wide – did not come until 10 minutes from halftime through Costa Rica's 30-year-old Joel Campbell.