South Korea's Hwang Hee-chan scored in added time to snatch a 2-1 comeback win over Portugal on Friday but they then faced an agonising 10 minute wait on the pitch before discovering it was enough to send them into the World Cup last 16 on goals scored.
Having started the day bottom of Group H, Korea looked to be going out with a whimper as they trailed already-qualified Portugal 1-0, with Uruguay leading Ghana 2-0 half an hour into their game.
But when Kim Young-gwon levelled after 27 minutes they knew one more goal could be enough - providing Uruguay did not extend their lead.
It came when talisman Son Heung-min broke from a Portugal corner and slipped a perfect pass to Hwang who fired past Diogo Costa to spark wild celebrations.
However, the other game had started its second half seven minutes later, leaving the Korean players and staff in a centre circle huddle, watching the action unfold across the city on mobile phones.
Another goal would have put the South Americans through but, though they piled forward, it did not materialise and the Koreans exploded in joy at having reached the knockout phase for the first time since 2010 - when they lost to Uruguay.
Portugal top the final standings on six points.
South Korea and Uruguay have four points with the same goal difference but Korea went through to the knockout stage by virtue of scoring four goals to two of Uruguay, who before Friday were the only team in the tournament not to have scored.
"I've been waiting for this moment a long time and I believed we could get it done," said Son, appearing in his third World Cup.
"I have not been doing a good job as their captain, but my team mates have covered my back. I am so thankful for them and so proud of them.
"They never gave up and made sacrifices for the team."
Goalscorer Hwang said: "I was convinced he would pass me the ball. It was an excellent pass and it made my job much easier.
"It was difficult waiting for the Uruguay-Ghana result but we proved we could make the knockout phase. I would like to share these great feelings with the people back home.
The turnaround marked a third successive World Cup night of nerve-shredding drama and also made it the first time three Asian Confederation teams have made the last 16 with Japan and Australia also through.
Korea are likely to face Brazil next, depending on the results in the later Group G games. They will again be outsiders but, having scored four of their last seven World Cup goals in the 90th minute or beyond, have shown they never give up.
South Korea did not get off to a great start on Friday as winger Ricardo Horta put Portugal ahead in the fifth minute when he tucked away a neat cut-back by Diogo Dalot.
Korea levelled when Kim forced the ball home after a corner.
Cristiano Ronaldo, seeking a goal to equal Eusebio's national World Cup record of nine, struggled to make an impact, though Kim Seung-gyu did save one sharp early effort.
The Portugal captain had another one-on-one with Kim but his effort was too weak to trouble the keeper and he was eventually taken off after 65 minutes.
Korea struggled to get a strong foothold in the game but, just as they did in vain in their defeat by Ghana, they showed an amazing commitment to keep going - and eventually reaped the reward.
Portugal will now face the runners-up in Group G - likely to be Switzerland, Cameroon or Serbia.
“We wanted to go through with a win, we wanted to go through playing good football,” coach Fernando Santos said. “We’re not going to lose confidence but it’s a warning, a serious warning.”