Portugal have claimed first position in Group H despite the defeat, with Fernando Santos's side set to take on the runners-up of Group G in the round of 16 on Tuesday evening, which could be Brazil, Switzerland, Cameroon or Serbia.
South Korea were down and out until the final stages of the contest, with Hee-chan finishing past Diogo Costa to move his team above Uruguay into second position in the section on goals scored.
Santos's side entered the match knowing that they needed a point to be certain of finishing at the head of the group, and Ricardo Horta sent the European team ahead in the fifth minute of the contest.
Kim Young-gwon levelled the scores in the 27th minute, before South Korea, who had head coach Paulo Bento in the stands following his red card against Ghana last time out, won it in second-half stoppage time, but they then had to wait for Uruguay's game against Ghana to finish before their progression was confirmed.
Bento's side will now take on the winners of Group G in the next round on Monday, which could also be Brazil, Switzerland, Cameroon or Serbia.
Portugal will now be looking to progress past the round of 16 for the first time since 2006, when they finished in fourth position, but the defeat is a setback despite topping the section.
A Selecao took the lead in the fifth minute of the contest when Horta picked out the back of the net with a clever finish after an excellent run and cross from Diogo Dalot, who was introduced into the starting XI, with Santos shuffling his pack.
South Korea had the ball in the back of the Portugal net in the 17th minute through Kim Jin-su, but it was ruled offside, with the European nation surviving after some lacklustre defending.
Bento's side did manage to level the scores in the 27th minute, though, when the ball fell kindly for Young-gwon inside the Portugal box, and he smashed the ball past Costa from close range.
Dalot brought a smart save from South Korea's goalkeeper in the 34th minute, before Costa had to keep out an effort from Son Heung-min down the other end of the field.
Cristiano Ronaldo had the chance to send Portugal back ahead late in the first period when Vitinha's effort was palmed back into the penalty box by Kim Seung-gyu, but the number seven headed wide.
South Korea's goalkeeper was again called into action to keep out a strike from Horta, with the two sides entering the half-time interval all square.
Portugal boss Santos made three changes in the 65th minute, with Ronaldo one of those to depart, and Costa had to make two smart saves in the period that followed, first denying Son before keeping out a powerful drive from Hwang In-beom.
Rafael Leao fired past the post 20 minutes from time, before Joao Cancelo had one deflected wide late on, but South Korea won it in the final moments, with Son sliding a pass into Hee-chan, who finished into the back of the net to spark incredible scenes.
South Korea then had to wait for the final whistle to be blown in the match between Uruguay and Ghana, which the South American nation won 2-0 but were eliminated on goals scored.