Portugal snatched a dramatic equaliser deep into injury time to force a 2-2 draw with the United States and keep their World Cup hopes flickering.
Silvestre Varela headed in a cross from Portugal captain Cristiano Ronaldo in the fifth and final minute of stoppage time at the Amazonia Arena in Manaus to grab a vital point.
The last-gasp leveller deprived the United States of a famous win which would have seen them complete a remarkable qualification from Group G, which also includes Germany and Ghana.
It also saved Ronaldo and Portugal from an embarrassing first round elimination from a group they were firmly expected to qualify from.
The result leaves the United States and Germany level on four points in Group G, with Portugal and Ghana on one apiece.
A draw between the Germans and Americans in the final round of matches on Thursday would see both teams advance.
US coach Jurgen Klinsmann hailed his team’s heroic display.
“Obviously the last second is unfortunate but my guys were magnificent,” he said.
“We just have to get a result against Germany.”
The USA were left cursing a late equaliser just seconds from the final whistle after a battling performance.
Portugal winger Nani shot the Europeans into the lead on five minutes but Klinsmann’s side rallied thereafter and dominated for long periods.
They got their reward when Jermaine Jones equalised on 64 minutes with a rasping shot.
Then nine minutes from time Dempsey chested in a shot to put the USA 2-1 up.
It seemed as if that would be enough for victory but Portugal poured forward with one last desperate attack to score.
In other games on Sunday, teenager Divock Origi fired Belgium into the last 16 with a 1-0 win against Russia in Group H.
Algeria trounced South Korea 4-2 to notch a long-awaited first World Cup win in 32 years in the day’s other game.
Belgian substitute Origi pounced on 88 minutes to settle a drab encounter at the Maracana Stadium.
Belgium coach Marc Wilmots said Origi’s match-winning contribution illustrated the depth and hunger in his squad.
“I know people are not happy to be on the bench,” said Wilmots.
“But what is important is Belgium being able to rely upon totally devoted players when they are called upon.
“For the last 20 minutes I had people dying to be brought off the bench.”
The win saw Belgium guaranteed a place in the second round ahead of their final group game against South Korea.
But the defeat leaves Fabio Capello’s Russia facing a tense battle to qualify, with only one point from two games.
“Of course I still believe. We have no other option than to go out and beat Algeria,” Capello told reporters
Algeria thrust themselves into pole position to qualify along with Belgium after thumping South Korea in Porto Alegre in Group H’s other game.
It was Algeria’s first win at a World Cup since the 1982 finals in Spain.
Islam Slimani, Rafik Halliche and Abdelmoumene Djabou effectively settled the contest before half-time as Algeria raced into a 3-0 lead.
Son Heung-Min gave Korea hope five minutes after half-time, but Yacine Brahimi made it 4-1 on 62 minutes.
Koo Ja-Cheol added a consolation goal for Korea, who must now beat Belgium in their final match on Thursday to have any chance of making the last 16.