Costa Rica stunned Japan 1-0 thanks to a late goal at the World Cup on Sunday to blow Group E wide open and hand a potential lifeline to Germany.
Japan, who shocked four-time champions Germany 2-1 in their opener in Qatar, could have taken a giant stride towards the last 16 with a win.
Instead they laboured 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 (90 degrees Fahrenheit) 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 centre-back Kendall Waston took their place in an ageing XI which featured four players from the 2014 World Cup quarter-finals.
Japan (4-2-3-1)
Shuichi Gonda; Miki Yamane, Kou Itakura, Maya Yoshida (capt), Yuto Nagatomo; Wataru Endo, Hidemasa Morita; Ritsu Doan, Daichi Kamada, Yuki Soma; Ayase Ueda
Coach: Hajime Moriyasu
Costa Rica (5-3-2)
Keylor Navas; Keysher Fuller, Oscar Duarte, Francisco Calvo, Bryan Oviedo, Kendall Waston; Celso Borges, Yeltsin Tejeda, Gerson Torres; Anthony Contreras, Joel Campbell
Coach: Luis Fernando Suarez (COL)
Referee: Michael Oliver (ENG)
Agence France-Presse