Porto struggled to a 3-2 away victory over Galatasaray in their final Champions League group match last night - but the Turks stayed third in Group D and secured a spot in the Europa League's round of 32.
Porto, who had already secured top spot in the group, took the lead against the run of play in the 17th minute with a well-timed Felipe header.
Moussa Marega doubled the lead when he converted a 42nd minute penalty, finding the net for the fifth successive group-stage match.
The hosts, who needed a win to make sure of third place, had failed to score in the competition since September but broke their goal drought with a penalty of their own from Sofiane Fenghouli in first-half stoppage time.
The Portuguese weathered a Turkish offensive early in the second half and restored their two-goal cushion when Marega pounced on a defensive mistake and Sergio Oliveira finished off a quick move.
The Turkish side reduced the deficit through Eren Derdiyok in the 65th minute and could have drawn level if Feghouli had not hit the crossbar with his second penalty a minute later.
Lokomotiv Moscow were equally desperate for a win against already-qualified Schalke 04 to have any hope of snatching third place away from Galatasaray.
They could not find the back of the net, however, against the lacklustre Germans, who had already clinched second place and a spot in the knockout stage.
Schalke struck in stoppage time through Alessandro Schoepf to condemn the Russians to fourth place on three points, one behind Galatasaray.
All four teams in Group A went into last night's matches knowing where they stood.
Borussia Dortmund and Atletico Madrid were already through to the knockout phase, with Club Brugge third and Monaco fourth.
The only issue that was still unresolved was who would finish top.
Raphael Guerreiro's 15th-minute goal sent Dortmund on their way to victory - and top of the group - away to Monaco, while Guerreiro struck again two minutes from time to make sure of the victory.
Atletico went into last night's matches top of the group but their scoreless draw with Brugge sees them pipped at the top.