Anything but victory would have handed Southampton their return to the Premier League behind champions Reading and left the Hammers in the play-offs.
Saints remain favourites to follow the Royals up in second spot but at least Sam Allardyce's men have made the south coast club earn their reward on the pitch at Saturday lunchtime against already-relegated Coventry.
It looked like that may not be the case when Jermaine Beckford headed Leicester in front against the run of play.
But West Ham responded quickly through Winston Reid before Jack Collison smashed home the winning goal in the second half.
Joint-leading scorer Carlton Cole looked a handful on his return from a knee problem and it was his presence that forced a mistake from Sol Bamba inside his own penalty area after six minutes.
The Leicester centre-half dwelled on the ball, Cole dispossessed him and teed-up Gary O'Neil whose low shot was well held by Kasper Schmeichel getting down to his right at full stretch.
Cole went close himself with 15 minutes gone, glancing a header wide from Mark Noble's whipped free-kick.
Immediately afterwards, the England striker found himself bearing down on Schmeichel - with Wes Morgan in tow - after latching on to Noble's through-ball.
As Cole was about to pull the trigger 12 yards out, Morgan made a superb last-ditch tackle.
Leicester were forced into a change after 22 minutes when captain Richie Wellens limped off injured.
Lloyd Dyer replaced him and the winger almost made an immediate impact, crossing dangerously from the right but Beckford headed wide.
West Ham threatened again when Kevin Nolan volleyed a dropping ball narrowly wide from the left-hand side of the area.
It was against the run of play when Beckford put the hosts in front after 34 minutes.
Ben Marshall evaded Matt Taylor down the right and crossed for Beckford to plant a header past Robert Green.
But it was a terrific response from the promotion chasers, who were level within five minutes. Taylor whipped in a brilliant low cross and Reid poked home from inside the six yard box.
James Tomkins almost sent the Hammers into half-time in front but his header from another Taylor cross went inches wide.
Perhaps concerned by the number of chances West Ham were creating, Leicester boss Nigel Pearson made another change at the break. Sean St Ledger replaced King, with Bamba moving into midfield.
However, West Ham still created opportunities and should have gone ahead after 57 minutes but Nolan miscued horribly from a useful Noble pass. A minute later though it was 2-1 as Collison thumped a powerful 18-yard effort beyond an unsighted Schmeichel after St Ledger had initially blocked a shot from O'Neil.
The visitors took their foot off the gas a little, perhaps trying to defend what they had, but still looked a threat on the break.
Ricardo Vaz Te and Collison passed up the chance to settle the game between them with 16 minutes remaining - both hesitating inside the box to allow former Hammer Paul Konchesky to make a brilliant saving tackle.
West Ham came within inches of a third goal late on as Taylor's low cross from the left was turned inches past his own post by St Ledger.
Nolan then spurned a one-on-one in injury-time, tamely shooting straight at Schmeichel.
And the Hammers were almost made to pay for their latest missed chance but Green hung on to Morgan's header at the death.