Poland can prepare for a European Championship last-16 meeting with Switzerland after Jakub Blaszczykowski's crisp, second-half goal beat the already-eliminated Ukraine 1-0 to reach the knockout stage for the first time.
Poland had started strongly but appeared to be settling for the draw that would also have guaranteed their progress until Blaszczykowski struck nine minutes after joining the fray as a halftime substitute.
The result left them on seven points, second in Group C on goal difference to Germany, who beat Northern Ireland 1-0.
Poland's huge following in the Stade Velodrome celebrated the win and the progress it brought with extra gusto, having had to endure the humiliation of four years ago when they finished bottom of their group when co-hosting the tournament.
"It is a very good result overall to get seven points without conceding a goal," said coach Adam Nawalka.
"We started fairly well but lost control of the midfield. The team played very well defensively and we had to show character."
Poland could and should have been out of sight in the first five minutes as Arkadiusz Milik shot straight at goalkeeper Andriy Pyatov when through and Robert Lewandowski, the leading scorer from any country in the qualifying competition but without a goal now in six internationals, side-footed wide with the goal gaping.
Ukraine looked shellshocked but, unlike in their previous two 2-0 defeats by Germany and Northern Ireland, they settled down and should have scored themselves when Andriy Yarmolenko blazed wide.
A goalless draw would have been enough for Poland to advance whatever happened in the other game but their grip on second place was strengthened when Germany went ahead in Paris after half an hour and some of the intensity went out of their approach.
But they looked fired up again after the break and an incisive pass by Milik sent Blaszczykowski through and the substitute checked inside to create space before smashing the ball firmly beyond Andriy Pyatov.
Midfielder Bartosz Kapustka, who will miss the Switzerland game after collecting a second tournament booking, should have doubled the lead two minutes later but shot wide from close range.
Poland then packed their midfield and sat deep and although it allowed Ukraine to have more possession, unleash a few pot-shots and force some desperate last-ditch Polish tackles, they never really threatened an equaliser.
Ukraine go home without a point or a goal and are now without a coach after Mykhailo Fomenko had announced before the game that he would step down.
"The level of skill is different in the Ukrainian league and we have to continue to work very hard to close the gap on the other countries," said Fomenko, who looked emotionally drained.