Substitute Bobby Zamora, who almost signed for Stoke at Christmas, rolled in a crucial goal to give West Ham's play-off hopes a vital boost.
Zamora, an £800,000 transfer target of City manager Tony Pulis, had been on the pitch for less than two minutes when he struck.
Marlon Harewood swept past Clint Hill in the penalty area to deliver a low cross and the unmarked Zamora was left with a simple task from three yards.
Stoke, who put in a sterling effort considering they had little to play for, thought they had equalised in stoppage time but Lewis Neal's strike was ruled out for offside.
The best action of the first half came inside the opening 50 seconds when both sides had opportunities to score.
There were just 20 seconds on the clock when Kenwyne Jones brushed aside Elliott Ward and tested James Walker with a well-struck shot.
But the Hammers had a much better chance on the counter-attack and Shaun Newton crossed for Harewood to blaze over from ten yards.
Harewood finally drew a decent save from Steve Simonsen when he latched on to a slip by Gerry Taggart in the 38th minute.
But the visitors failed to make the most of a wealth of possession and Ward cleared off the line from Clive Clarke after Walker spilled a cross three minutes before the break.
Surprisingly, Stoke showed the greater urgency for much of the second period and almost took the lead when Gifton Noel-Williams crashed his shot into the side-netting.
But Zamora, who fired inches over just seconds after coming on in the 76th minute, provided the spark to secure an invaluable victory.