A thrilling last-gasp victory over 10-man Aston Villa hauled West Ham out of the Premier League drop zone for the first time since late September.
Mark Noble converted a West Ham penalty on the stroke of half-time.
Robert Green saved an Ashley Young spot kick shortly after the break, but levelled soon afterwards with a curling effort that was more cross than shot.
Habib Beye saw red late in the game before substitute Zavon Hines prodded home from close range at the death.
After a torrid start to the campaign, West Ham's first home victory in the Premier League this season - and first win anywhere since the opening day - should do much to lighten the mood in E13.
But Villa manager Martin O'Neill will be desperately disappointed by his side's failure to reap greater benefit from a first-half spell in which West Ham were twice forced to regroup in the wake of injuries at both ends of the pitch.
Defensive lapses have repeatedly proved costly for West Ham since James Collins' defection to Villa two months ago, a situation which manager Gianfranco Zola sought to address by drafting in Julien Faubert and Manuel Da Costa, for Jonathan Spector and James Tomkins respectively.