South Korea finished second in their Asian Cup Group E after Malaysia held them to a 3-3 draw on Thursday with an equaliser in the 15th minute of added time.
This result saw Bahrain finish top with a 1-0 win over Jordan.
Bahrain finished with six points thanks to an Abdulla Yusuf Helal winner while South Korea finished with five points.
Jordan ended the group campaign with four points and also went through as one of the best third-placed teams.
South Korea will wait to see who they play in the last-16 and coach Juergen Klinsmann said they did not deliberately finish second to avoid a titanic clash with Group D runners-up Japan, adding that he was angry with the result.
"We didn't want to avoid Japan, it definitely wasn't our plan to concede three goals today. We wanted to go through in first place, that was our goal," Klinsmann told reporters.
"Malaysia played with a lot of heart and you have to give them credit but we should have won this game."
South Korea opened the scoring in the 21st minute when Jeong Woo-Yeong headed home from a corner. The goal was initially not awarded as Malaysia keeper Syihan Hazmi clawed the ball out of the air before VAR confirmed it had crossed the line.
However, Malaysia equalised six minutes into the second half when they won the ball back high up the pitch before Faisal Halim twisted and turned in the box to score from a tight angle.
Malaysia then took the lead 11 minutes later when Arif Aiman was fouled in the box by Seol Young-Woo and awarded a penalty after a VAR check, with the forward stepping up himself to put it away.
The game had late drama when Lee Kang-in restored parity in the 83rd minute when his free kick into the top corner went in off the woodwork after Hazmi attempted a save, with the strike going down as an own goal.
South Korea won a penalty in injury time with another VAR check after the referee deemed Oh Hyeon-Gyu to have been fouled when he was sandwiched between two defenders while vying for the ball, with Son finding the bottom corner from the spot.
But with virtually the last kick of the game in the 15th minute of stoppage time, Romel Morales equalised at the other end to spark wild celebrations among the Malaysian fans behind the goal.
"For us it's a fantastic result. Congratulations to all Malaysian fans, I appreciate the support we had. I'm grateful to all the players for what they've done," Malaysia's South Korean coach Kim Pan-gon said.
In the other game, Bahrain netted the winner from a counter-attack in the first half when Helal sprinted from the centre circle with just the keeper to beat and pulled the trigger from outside the box to score.
Bahrain will play Japan in the next round while Jordan will also wait to discover their last-16 opponents.