Stoke City lost for the first time in the Europa League and were forced to settle for second place in Group E, as Besiktas triumphed 3-1 in Turkey.
The Premier League side took an unlikely lead in the first half.
With Besiktas having dominated the early proceedings against a Potters side who made 11 changes from the win over Spurs, Richardo Fuller took advantage of some poor defending to shoot home from 25 yards, via a deflection off Egemen Korkmaz.
The Jamaican almost doubled Stoke's lead shortly after the restart but he failed to get the final touch he needed after charging down Rustu Recber's kick.
The match turned with the sending off of Matthew Upson, with Manuel Fernandes stepping up to slot home the resulting penalty.
The home side took the lead when Fernandes fed substitute Mustafa Pektemek, before his fellow replacement Edu's fierce strike sealed the victory.
Stoke's qualification for the last 32 had already been sealed.