DOHA, Qatar - A late goal by substitute Niclas Fuellkrug allowed Germany to snatch a 1-1 draw with Spain on Sunday as the four-time winners kept their World Cup hopes alive, but Belgium are in danger of a group-stage exit after losing to Morocco.
Elsewhere, 2018 runners-up Croatia crushed Canada 4-1 to eliminate their opponents while Costa Rica claimed a shock win over Japan.
Keysher Fuller's 81st-minute goal for Costa Rica at Doha's Ahmad Bin Ali Stadium in Sunday's early game eased some of the pressure on the Germans as it prevented Japan from taking a giant stride towards the last 16.
Hansi Flick's German side nevertheless desperately needed something from their meeting with 2010 winners Spain at Al Bayt Stadium in Al Khor, north of Doha, after losing 2-1 to Japan in their Group E opener.
Yet they were in big trouble when substitute Alvaro Morata turned in Jordi Alba's cross to put Spain ahead just after the hour mark.
However Germany, who had an Antonio Ruediger goal disallowed for offside in the first half, had a substitute of their own to thank as Werder Bremen striker Fuellkrug lashed in an 83rd-minute leveller on just his third international appearance.
"We still have room for improvement, but we can hope that everything turns out well in the final game," Fuellkrug, 29, told German broadcaster ZDF.
His side are still bottom of Group E on a single point, with Japan and Costa Rica on three each while Spain sit top with four.
To avoid a second consecutive group-stage exit, Germany must win their final group match against Costa Rica on Thursday and hope that Spain avoid defeat to Japan.
Spain will definitely qualify with a point against Japan, who now must win that game to give themselves the best possible chance of progressing to the next round.
"Of course Spain will be tough but there is a good chance for us to win," said Japan coach Hajime Moriyasu.
"We will be well prepared and will go into the match with confidence."
Croatia knock Canada out
Meanwhile, Belgium are themselves in trouble in Group F following their deserved 2-0 defeat at the hands of Morocco.
A victory for Belgium would have sent them through but Romain Saiss and Zakaria Aboukhlal's late goals instead secured Morocco a first World Cup win in 24 years.
Belgium, who finished third in 2018, lacked spark and were made to pay by inspired opposition.
"We're not playing with joy. It's maybe the weight on our shoulders," said coach Roberto Martinez.
"In the last game we have to play to win it and as if we have nothing to lose."
In Sunday's other game in the same section, Croatia went behind to Canada at the Khalifa International Stadium when Bayern Munich's Alphonso Davies scored after just two minutes.
However, the beaten 2018 finalists exploited the gaps in the Canadian defence as they roared back to claim a much-merited victory.
Andrej Kramaric scored twice either side of a fine goal from Marko Livaja before Lovro Majer completed the job in second-half injury time.
Croatia now need just a draw to reach the last 16 when they meet Belgium in their final group game on Thursday, but the Belgians must win to be sure of going through.
The Moroccans will be confident of taking a point from Canada which would send them through.
John Herdman's side now cannot progress and Canada have lost all five matches at the World Cup finals after they failed to collect a point on their previous appearance in 1986.
On Monday, Brazil and Portugal both have the chance to join defending champions France in the last 16 with one group game to spare.
Five-time winners Brazil will be without Neymar, who has an ankle injury, as they take on Switzerland after Group G rivals Serbia and Cameroon meet in Monday's early game.
Brazil and the Swiss could both advance if they win, provided the other result goes their way.
Cristiano Ronaldo's Portugal side will qualify if they beat Uruguay, with South Korea meeting Ghana in the other Group H match.
© Agence France-Presse