Porto struggled to a 3-2 away victory over Galatasaray in their final Champions League group match on Tuesday 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 from a free kick.
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 did break 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 Algeria international Feghouli had not hit the crossbar with his second penalty a minute later.
Lokomotiv Moscow were equally desperate for a win against already-qualified and injury-hit 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 competition's knockout stage.
Schalke struck in stoppage time through Alessandro Schoepf to condemn the Russians to fourth place on three points, one behind Galatasaray.
Porto finished top of Group D on 16 points and undefeated, with Schalke second on 11.