Viktor Claesson scored a goal at the death to ensure Sweden top Group E following a dramatic 3-2 victory over Poland, who exit the competition.
Starting the game bottom of the pool, Poland were required to win to progress but fell behind after just 81 seconds when Emil Forsberg struck with the second-fastest goal in the history of the European Championships.
Robert Lewandowski blew a gilt-edged opportunity to level the scores, crashing a header off the crossbar from Pior Zielinski's superb corner delivery and then somehow failing to score from the rebound, heading back onto the woodwork from just two yards out.
World Cup Qualification UEFA
Elanga subjected to alleged racist abuse, Swedish FA says
Substitute Dejan Kulusevski sparked Sweden into life and the Juventus forward was at the heart of his side's second, racing down the channel before teeing up Forsberg for his second of the game and third of the tournament in the 59th-minute.
But barely two minutes later, Lewandowski's beauty gave Poland a lifeline, as he became his country's all-time top goalscorer in the Euros with a breathtaking curling shot. It was the first time Sweden had conceded in this year's competition.
That gave Poland fresh impetus and Jakub Swierczok thought he had grabbed the equaliser only for the offside flag to go up.
With six minutes remaining, Lewandowski scored his third of the tournament, wriggling free inside the box to finish from Przemysław Frankowski's cross to finally restore parity and set up a dramatic finale.
There was to be one more goal in the contest - but it wasn't scored by Poland. Having committed players forward, Paulo Sousa's men were caught short defensively as Kulusevksi set fellow substitute Claesson free and he made no mistake to break his opponent's hearts in the fourth minute of added-time.
Sweden's reward is a last-16 tie with a third-placed side on Tuesday night in Glasgow.
TALKING POINT - Sweden brush off 'boring' tag with thrilling display
It's a shame this roller coaster contest had to come to an end.
Having been accused of stinking the competition out in their opening two games, Sweden took the handbrake off after their place in the last-16 was secured following Monday night's results. After this ruthless showing, Emil Forsberg is now the tournament's joint top goalscorer. But it was Kulusevski who was the real star of the show. Sweden immediately shifted into a higher gear when he was introduced in the 55th-minute for his first appearance in the competition. It was a performance that proved manager Janne Andersson has a Plan B if their pragmatic approach isn't proving effective.
As for Poland and Lewandowski, well their talisman certainly upheld his end of the bargain, as expected. Unfortunately his team mates haven't been on the same wavelength and although their efforts were credible, it wasn't enough.
Kulusevski impressed despite only featuring as a substitute
Image credit: Getty Images
MAN OF THE MATCH - Dejan Kulusevski
He may have only been on the pitch for 40 minutes, but Kulusevski was a breath of fresh air. His direct running, pace, trickery and delivery caused chaotic for Poland's defenders, who simply couldn't deal with him.
Sweden: Olsen 7; Lustig 7, Lindelof 7, Danielson 6, Augustinsson 6; Ekdal 7, Olsson 7, S Larsson 7, Forsberg 8; Quaison 5, Isak 7.. subs: Krafth 5, Claesson 6, Kuluvsevski 9.
Poland: Szcznesy; Bednarek, Glik, Bereszynski; Klich, Krychowiak; Puchacz 4, Zielinski, Swiderski, Jozwiak; Lewandowski.. subs: Kozlowski 5, Placheta 5, Frankowski 7, Swierczok 7.
2' GOAL! Sweden 1-0 Poland (Emil Forsberg): It's a nightmare start for Poland as Forsberg rifles home the opening goal to give Sweden the lead! Isak is involved - of course he is - as he holds the ball up, Forsberg takes control and he takes full advantage of some slack defending to find the bottom corner for his second goal of the tournament.
17' - Poland hit the bar, twice! Oh my, how has that not gone in?! It's remarkable! Zielinkski's corner delivery is exceptional and finds Lewandowski, whose bullet header crashes off the crossbar. The Bayern Munich talisman is well placed to convert from the rebound but, somehow, heads back onto the woodwork from two yards out.
59' - GOAL! Sweden 2-0 Poland (Emil Forsberg): A textbook counter-attacking goal, made by Kulusevski! He leads the Swedish break with rapid pace as he drives down the right flank before looking up, carving inside and laying it off to Forsberg, whose first-time shot nestles into the bottom corner.
61' - GOAL! Sweden 2-1 Poland (Robert Lewandowski): Poland aren't out of this just yet! It's a world class finish from Lewandowski, who is doing his best to keep his side's last-16 hopes alive. Zielinski sets him free with a fine pass through the middle, Lewandowski takes control even after being forced wide as he curls a breathtaking shot into the far corner.
66' - Goal ruled out! Much more urgency about Poland now and Swierczok thinks he has drawn them level, but the offside flag is up and VAR confirms the goal won't count. It was close!
84' - GOAL! Sweden 2-2 Poland (Robert Lewandowski): He's not going to miss from there, and Poland are level in the game! One more goal will take them through! Both of Sweden's centre-halves are attracted to the ball and leave Lewandowski free to meet Frankowski's cross. He looks up and slots it home. Five minutes to grab a winner!
90'+4 - GOAL! Sweden 3-2 Poland (Viktor Claesson): Heartbreak for Poland as Claesson seals the victory for Sweden after a beautiful pass from Kulusevski, as the subs combine!
- Dejan Kulusevski (21y 059d) is the youngest player to assist two goals in a single game at the European Championships since Cesc Fàbregas (21y 053d) v Russia in 2008.
- Robert Lewandowski has scored 69 goals for Poland in all competitions, more than twice as many as the rest of the Polish EURO 2020 squad have netted combined for the nation (34).
- Lewandowski scored his fourth European Championship goal for Poland, overtaking Jakub Blaszczykowski (three) for the most by any player for the country in the competition.
- Scored after just 81 seconds, Emil Forsberg's opener for Sweden against Poland is the second-fastest goal ever scored from the start of a European Championship match, after Dmitry Kirichenko for Russia v Greece in 2004 (65 seconds).
UEFA Nations League
'Nobody understands Enrique's choices' - Why Spain is divided ahead of Italy clash
World Cup Qualification UEFA
Glik reported by England after appearing to pinch Walker's neck