Winger Emil Forsberg scored a double, including the second fastest strike in European Championship history, before Viktor Claesson's stoppage-time goal to help Sweden seal a 3-2 win over Poland on Wednesday and top Group E, heading into the last-16.
Sweden will next face one of the third-placed sides from Groups B, C or D - Finland, Ukraine or the Czech Republic - in Glasgow on June 29.
Spain, who finished second following their 5-0 win over Slovakia in the other Group E match, face Croatia in Copenhagen a day earlier.
It was a heartbreaking end to Poland's campaign after they twice drew level through talismanic skipper Robert Lewandowski, whose 84th minute equaliser for 2-2 gave them a glimmer of hope.
Sweden's previous two matches were built on robust defensive displays that had cast doubts on whether Janne Andersson's side could get their attack firing, but they made a blistering start through the lively Forsberg.
After Robin Quaison controlled the ball on the edge of the penalty area, Forsberg collected a pass and took advantage of some poor defending to fire past goalkeeper Wojciech Szczesny with 82 seconds on the clock.
He doubled their lead with a powerful drive for his third goal of the tournament after substitute Dejan Kulusevski weaved his way into the box to lay it on a platter in the 59th minute.
Lewandowski pulled a goal back two minutes later with a curling shot before Jakub Swierczok's tap-in from substitute Przemyslaw Frankowski's pass was ruled out for offside after the Video Assistant Referee's intervention.
Lewandowski, who missed chances to make it 1-1 in the first half after rising above Sweden's defence only to thunder two headers onto the crossbar, fired in the equaliser from close range after a pass from Frankowski.
But Sweden were not done yet, as Kulusevski slipped the ball to Claesson who slotted past Szczesny to secure the win.
"It was a rollercoaster emotionally. It was 2-0 and as calm as it could be, then they got back into the game and got two goals," Claesson told Sweden's TV4.
"From 2-1, there's always pressure there. It's hard to do anything but defend in those situations when they have that kind of momentum. We'll hopefully get a slightly easier opponent in the last 16."