Thanks to a 121st-minute winner from Artem Dovbyk, Ukraine and manager Andriy Shevchenko have sealed a spot in the quarter-finals after downing 10-man Sweden 2-1 on Tuesday.
Oleksandr Zinchenko put Ukraine ahead on 27 minutes in Glasgow but Emil Forsberg equalised for Sweden before half-time with his fourth goal of the tournament.
Centre-back Marcus Danielson was sent off for Sweden in extra time before Dovbyk headed in a Zinchenko cross in stoppage time to send Ukraine through to face England in Rome on July 3.
Despite taking just three points in the group stage, qualifying in part because Sweden beat Poland to top Group E ahead of Spain, Shevchenko's side have shown immense courage and heart throughout the tournament.
After Zinchenko opened the scoring, Emil Forsberg's deflected strike brought Sweden level before half-time and the RB Leipzig midfielder twice hit the woodwork in the second half.
But the red card for Danielson nine minutes into extra time left Sweden hanging on for penalties until the Dovbyk goal sparked wild scenes of celebration among the small band of Ukrainian fans at Hampden Park.
Shevchenko said before the game his side had already achieved their objective by making it through the group.
But the former AC Milan striker got the reaction he desired after a disappointing 1-0 defeat to Austria in their final group game with a fast start.
Sweden's Robin Olsen was forced into the first save to deny Roman Yaremchuk after he was teed up by the impressive Andriy Yarmolenko.
The West Ham United winger has been his country's driving force all tournament, scoring or assisting in all but two of their six goals.
Yarmolenko's teasing cross with the outside of his left foot fell kindly for Zinchenko on 27 minutes and the Manchester City man drilled in a low shot that had too much power for Olsen.
That was the first time Sweden had trailed all tournament, but Janne Andersson's men responded well to the questions asked of whether they could chase a game after their defensive discipline shone through in the group stage.
Forsberg has been just as influential for Sweden as Yarmolenko for Ukraine and he equalised two minutes before the break with his fourth goal of the tournament.
Chances came and went for both sides as an entertaining second half raged from end to end.
Yarmolenko teed up Serhiy Sydorchuk to smash against the post, but Sweden posed the bigger threat.
Forsberg hit the woodwork twice, curling a shot onto the base of the post before a more powerful effort from the edge of the box cannoned back off the bar.
In between times, Georgiy Bushchan produced a stunning save to tip over Dejan Kulusevski's dipping shot.
Ukraine survived to take the game into extra time and were gifted a golden chance to reach the last eight of a major tournament for just the second time as an independent nation when Sweden were reduced to 10 men.
Danielson won the ball but followed through with a dangerous challenge on Artem Besedin that forced the Dynamo Kiev striker to come off injured.
Yarmolenko also had to be replaced midway through extra time in what will be a concern for Shevchenko if Ukraine are to have any chance of shocking England in Rome.
But his replacement Dovbyk was the hero as he chose the perfect time to score his first international goal.