Spain, in only their third Olympic appearance in the women's event, held their nerve against the twice winners, who finished off the podium for only the second time in eight appearances.
Jessica Alonso scored the game's final goal late in the second period of extra time after the teams had finished level after normal time and the first period of extra time.
Second-choice goalkeeper Mihaela Ciobanu came on just for penalties and saved four of the five she faced to help Spain to a famous victory.
Olympic Games
Handball future 'reliant on UK Sport funding'
16/12/2012 AT 15:09
A topsy-turvy encounter sprang to life in the final seconds of normal time with Korea goalkeeper Ju Hui keeping the scores level at 24-24 when Begona Fernandez turned and shot on target.
The Koreans then roared up the other end only to have a goal on the buzzer disallowed for an attacking foul.
South Korea had a four-goal lead in the first half and could have made it five but for a good save by diminutive Spanish keeper Silvia Navarro. A few minutes later, Spain were ahead after six straight strikes.
Suddenly the Spaniards, who seemed out of their depth against the prolific Koreans, found some form and when they surged into a four-goal lead after less than eight minutes of the second half they looked comfortable.
But Spain, who finished third at the 2011 world championship, buckled under Korean pressure in normal time and the deficit was dragged back forcing extra time.
Holders Norway play debutants Montenegro at 1930 GMT for the gold medal.
Olympic Games
British handball's Wiiliams fumes at expected cut in funding
17/08/2012 AT 13:48
Olympic Games
France beat Sweden to win handball Olympic gold
12/08/2012 AT 15:45