Kemar Roofe's winner sent Rangers into the Europa League last 16 with a 3-2 victory at Real Betis on Thursday, while Joao Pedro's late strike helped Brighton sink Marseille.
Rangers, runners-up in the competition two seasons ago, were heading out of the tournament and into the Europa Conference League with the game level 12 minutes from time and Sparta Prague on their way to a 3-1 victory at Aris.
But after a corner was twice not cleared, Roofe bundled the ball home from three yards out to fire Rangers from third to first in Group C.
Brighton avoided a Europa League knock-out round play-off in February with a tense 1-0 home win over Marseille in Group B.
Pedro showed neat footwork in the box before drilling the ball into the top corner in the 88th minute to score his sixth goal in as many Europa League matches this season.
West Ham finished top of their group as Mohammed Kudus and Edson Alvarez scored in a 2-0 win over Freiburg, who finished second in Group A.
Earlier, a youthful Liverpool side lost 2-1 at Union Saint-Gilloise in their final group game.
Liverpool manager Jurgen Klopp rang the changes with his team already secure as Group E winners and with an eye on the weekend's Premier League game against rivals Manchester United, starting six players aged 20 or younger.
Saint-Gilloise, who needed a victory to keep alive their hopes of pipping Toulouse to second place, took the lead through Mohamed Amoura before Jarell Quansah hit back for Liverpool.
Cameron Puertas restored the hosts' advantage two minutes before half-time with a low strike which beat Caoimhin Kelleher at his near post.
Klopp threw on Joe Gomez, Ryan Gravenberch and Darwin Nunez in the second half, but Saint-Gilloise held on for a famous win, although the Belgians dropped into the Europa Conference League play-off round after Toulouse beat LASK Linz 2-1 in the group's other game to finish second.
Dani Parejo scored a late winner as Villarreal took top spot in Group F and direct qualification for the last 16 with a 3-2 victory at Rennes.
Azeri club Qarabag finished second in Group H courtesy of a 2-1 success against Haecken.
They were a distant eight points adrift of group winners Bayer Leverkusen, though, as the Bundesliga leaders extended their unbeaten start to the season to 23 matches in all competitions by thrashing Molde 5-1. (AFP)