Ri Un Suk struck for North Korea in the 22nd minute with a superb 30-metre missile to crush the dreams of the European giants who needed a huge victory to catapult them into the knockout stage.
Charlotta Schelin was the hero for Sweden, scoring two goals to hand her team their first World Cup victory of 2007. But it was little consolation for the 2003 runners-up who needed to win by three clear goals to qualify.
Sweden opened the game with an intensity missing from their earlier games, repeatedly attacking the North Korean goal and applying ferocious tackles.
They were rewarded almost straight away, with Schelin rising above the defence to head home a cross from Therese Sjögran in the fourth minute.
Sweden pressed on, with fast and furious attacks that saw their forwards camped in North Korean territory.
But North Korea hit back in the 22nd minute, Ri beating her defender to launch a bullet from her right foot that curled into the far corner of the net, past diving goalkeeper Hedvig Lindahl.
Disaster struck for Sweden close to half-time when veteran campaigner Hanna Ljungberg limped off for apparent treatment to her left thigh and took no further part.
Despite the blows, the Swedes came out firing in the second half, Schelin pouncing on a through ball in the 54th minute to charge through two defenders and fire past advancing goalkeeper Phi Un Hui.
Both sides continued to mount attacks, and frustration grew in the Swedish camp as they were unable to to find a way through the tiring defence.
North Korea finished second in their group behind the United States who downed Nigeria 1-0 also on Tuesday.
The Koreans now take on world number two and defending champions Germany in a quarter-final showdown on Saturday.
North Korea, who failed to reach the knockouts in their previous two World Cup campaigns, have impressed in China by downing African champions Nigeria and holding world number ones the US to a 2-2 draw.