West Ham failed to secure a place in next season's Europa League after losing 2-1 at Stoke City as Mark Hughes' men came from behind to end the season by halting their six-game winless streak.
A victory would have confirmed European football for Slaven Bilic's men, but Southampton's victory over Crystal Palace coupled with the abandonment of Manchester United's match against AFC Bournemouth due to a suspect package at Old Trafford leaves West Ham in seventh.
Michail Antonio gave West Ham the lead at the Britannia Stadium, finishing powerfully on the turn after a corner, but Stoke felt the winger handled the ball in the build-up.
Giannelli Imbula fired in from just outside the box soon after the interval and Andy Carroll suffered a groin injury, damaging his Euro 2016 selection hopes, while Glenn Whelan made two fantastic goalline clearances to keep Stoke level.
And Stoke snatched victory with two minutes left when Mame Biram Diouf powered in a header from Charlie Adam's corner.
Stoke's first win in seven games means they finish in the top half of the Premier League, while West Ham's five-game unbeaten run away from home in the Premier League ended.
Manuel Lanzini had an early effort blocked as the opening exchanges had a strong end-of-season feel before West Ham took the lead in controversial circumstances after 23 minutes.
Winston Reid kept Lanzini's deep corner alive and Antonio appeared to control the ball high on his arm before swivelling and firing in a low shot that beat Imbula on the line.
Diafra Sakho went close to scoring a second for West Ham when Antonio's centre picked him out at the back post, but the striker's shot hit the side netting.
Shay Given saved Sakho's scuffed shot easily after 35 minutes, then Bojan Krkic fired wide as Stoke struggled to get a foothold in the game.
West Ham were dominating even without the injured Dimitri Payet and Sakho should have doubled the lead five minutes after half-time from Antonio's pass, but Given made a good save.
And Sakho's profligacy in front of goal was then punished as the hosts levelled after 55 minutes.
Imbula found room outside the box and smashed a low drive across Darren Randolph, giving the goalkeeper no chance with the left-footed shot.
Carroll's slim chances of a call-up to England's Euro 2016 squad were then dealt a blow when the striker suffered a groin strain and had to be substituted.
Replacement Enner Valencia could have restored West Ham's lead after 69 minutes, but misjudged his header from Mark Noble's cross, directing the effort over the crossbar.
The visitors continued to push hard and Whelan made two brilliant goalline clearances in the space of three minutes.
Adam let fly from just inside his own half, Randolph backpedalling to tip the substitute's spectacular strike over, but Stoke did snatch maximum points with two minutes to go.
Adam's corner was perfectly flighted for Diouf to attack and power in an unstoppable near-post header.
Randolph went up for a free-kick in the seventh minute of added time and headed wide, meaning West Ham can now only qualify for Europe if Manchester United beat Palace in the FA Cup final next weekend.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.