Jack Collison fired West Ham to their first Premier League away win since November to stun Stoke and lift them nine points clear of the drop zone.
Substitute Collison latched on to a Ricardo Vaz Te pass before angling the winner past home keeper Asmir Begovic.
Begovic kept out a Matt Jarvis strike, while Stoke went close through a long-range Peter Crouch effort.
Charlie Adam almost equalised with a 22-yard shot which hit the crossbar for a labouring Stoke.
An injury-time Gareth Bale goal had inflicted a painful defeat for the Hammers against Tottenham on Monday but, to their credit, they resolutely held on at the Britannia Stadium, albeit with the help of the woodwork.
Stoke suffered only a second home defeat of the season and, despite manager Tony Pulis throwing on plenty of his attacking players in search of a goal, they were constantly repelled by the visitors.
The victory moved West Ham level on points with Stoke who have now lost six out of their last eight league matches.
The Hammers had been forced into some early readjustments, with midfielder Matt Taylor and playmaker Joe Cole having to go off injured in the first 11 minutes.
"What a way to end a run of five away defeats in the league. West Ham boss Sam Allardyce must be so proud of his players. After having to make two early substitutions, the Hammers inflicted a only a second home defeat in the league for Stoke this season."
Taylor was helped off in a daze after being caught flush in the face by Crouch's foot when the striker was attempting an overhead kick while Joe Cole's involvement was ended by a hamstring problem. Collison and Vaz Te replaced the stricken Hammers duo.
West Ham showed the greater endeavour and energy, with defender James Collins going close when his glancing header from Gary O'Neil's cross grazed the top of the crossbar.
Stoke have relied on their home form for all but nine of their 33 points this season but they posed little threat and might have conceded a penalty for Ryan Shotton's clumsy challenge on Mohamed Diame.
West Ham won it when their two early substitutes combined. Vaz Te was the provider, playing in Collison after his initial pass came back to him off Stoke defender Ryan Shawcross, who had fallen to the ground as he tussled with Andy Carroll.
The Potters showed more urgency after the break but their appeals for a penalty were correctly ignored by referee Jon Moss after Cameron Jerome went down under a challenge by Joey O'Brien with the West Ham defender appearing to get a toe to the ball.
Hammers winger Matt Jarvis had a left-foot shot saved by Begovic and, at the other end, Crouch had a long-range effort kept out by visiting keeper Jussi Jaaskelainen.
Vaz Te could have given West Ham some breathing space but he dallied too long when given a sight of goal from Collison's pass.
Stoke again felt they should have had a penalty but Hammers defender Guy Demel survived a handball shout before Adam hit a powerful shot which crashed back off the crossbar.
- West Ham's goal was only their ninth away league strike of the season. Only hosts Stoke (8) have scored fewer on the road.
West Ham held out for a crucial win to give them some breathing space ahead of the trip to Chelsea in a fortnight while Stoke will wonder why their season has faded away since Christmas.
Stoke boss Tony Pulis: "We are disappointed with their goal because Andy Carroll drags Ryan Shawcross in the build up and I thought we should have got a free-kick.
"I thought we huffed and puffed and didn't get enough quality into the box. People will criticise the forwards for not scoring goals but they need the service.
"We have gone a bit flat. We missed Matthew Etherington and Robert Huth. We need them back, we need our best players."
West Ham manager Sam Allardyce: "We had to overcome the blow to losing Matt Taylor and Joe Cole early on.
"It is a fantastic and we deserved victory for us.
"When I saw Charlie Adam's shot - because of the number of wonder goals that have gone in against us - I thought not again but we got a bit of luck and the win."
Sorry, we were unable to load match stats, please try again.