A brilliantly worked goal by substitute Jakub Blaszczykowski sent Poland through to the last 16 of Euro 2016 with a 1-0 win over Ukraine in Marseille.
Blaszczykowski sent a superb left-footed finish past Ukrainian goalkeeper Andriy Pyatov after a sharp series of one-touch passes following a short corner in the 54th minute.
The win sent the Poles through behind Group C leaders Germany while already-doomed Ukraine will now exit their forgettable tournament both pointless and goalless.
Ukraine coach Mykhailo Fomenko, who had indicated he will quit after the tournament, made five changes to his starting line-up but it was the Poles who dominated the opening exchanges.
Arkadiusz Milik found space on the left flank in the third minute and cut inside before bringing a fine save out of Pyatov with a powerful rising shot.
One minute later Poland missed an even better chance when Milik crossed from the left and found Robert Lewandowski clear in front of goal, but the striker sent his shot over the bar.
Ukraine slowly began to edge into the game and had their first chance in the 10th minute when Roman Zozulya's close-range shot was brilliantly blocked by Michal Pazdan, and Andriy Yarmolenko missed the follow-up.
Yarmolenko proved one of his side's few attacking threats throughout and he came close again six minutes later when he sprinted into plenty of space on the right flank only to loft his shot wide of target.
A mistake by the ineffective Yevhen Konoplyanka gave Poland another goalscoring chance in the 21st minute, the ball squirting clear to Lewandowski who bore down on the Ukraine box only to screw his shot just wide.
Seemingly determined to sign off with a win despite their fate being sealed, the Ukrainians pressed in response with Konoplyanka testing Polish goalkeeper Lukasz Fabianski twice in quick succession.
Tomasz Jodlowiec shot straight at Pyatov to bring the first half to a close but there was hope for Ukraine early in the second half when Konoplyanka delivered a cross from which the impressive Alexander Zinchenko headed over the bar.
Poland snatched their opener in the 54th minute when Blaszczykowski, fresh from replacing Piotr Zielinski at the break, finished off a superb move to all but book his side's place in the knock-out stages.
Bartosz Kapustka should have increased Poland's lead two minutes later when he was sprung clear by Lewandowski but shot into the side-netting.
But Poland's move into the knock-out stages was blighted by a needless booking for Kapustka on the hour mark, his foul on Yarmolenko ensuring he will be suspended for their last-16 match.
Zinchenko screwed a good chance wide for Ukraine before Milik flashed a header just off target from a free-kick delivered by substitute Kamil Grosicki.
Vainly seeking to salvage something from a dismal tournament, Ukraine pressed in the dying minutes with Zozulya heading just wide and Ruslan Rotan bringing a fine low save out of Fabianski, but their efforts came to nothing.