Gabriel Agbonlahor propelled Aston Villa towards Barclays Premier League safety and edged West Ham towards relegation with an injury-time winner at Upton Park.
The Hammers had taken the lead inside two minutes with a strike from Robbie Keane but Villa wrestled back control with Darren Bent's header shortly before the interval.
West Ham goalkeeper Robert Green pulled off a string of top-class saves to keep his side in the game but Villa snatched a deserved victory with a header from substitute Agbonlahor in added time.
Villa thriller: Gabriel Agbonlahor celebrates after heading the winning goal at Upton Park
Villa's victory moved them up to ninth in the table on 40 points, seven clear of the drop zone, while Avram Grant's struggling side slipped deeper into trouble.
The Hammers have five games left to save their season. The next two are away at Chelsea and Manchester City.
West Ham had billed the game as a celebration of the 'Best of British' in anticipation of St George's Day and the Royal Wedding and there were 14 players from these shores in the two starting line-ups.
Scott Parker was missing for West Ham with a troublesome Achilles and replaced in midfield by Gary O'Neil while Carlton Cole, Victor Obinna and Lars Jacobsen all came into the team beaten 3-0 by Bolton last weekend.
Head boy: Agbonlahor rises high to nod the killer blow for Villa
Aston Villa featured two changes from their victory over Newcastle, with Emile Heskey and former Hammers captain Nigel Reo-Coker replacing Agbonlahor and Jean Makoun.
West Ham had promised a 'traditional street party atmosphere' and the Upton Park faithful were waving their claret and blue pennants inside two minutes after Keane opened the scoring.
O'Neil's blocked shot from a West Ham corner fell to Thomas Hitzlsperger, who lofted a header towards Keane on the edge of the six yard box. Keane was played on-side by Ashley Young, who had been marking the far post, and the on-loan Tottenham striker turned to rifle his shot past Brad Friedel.
Equaliser: Darren Bent (centre) notched Villa's reply
Keane was heavily involved in a bright West Ham start. He turned James Collins and played in Cole but the England striker was denied by Luke Young's block.
Villa came close to an immediate response when Young cut in from the left and ghosted past Jacobsen but his strike was deflected wide by Matthew Upson. Stiliyan Petrov's interception sparked another Villa attack and Heskey had Bent in support but he was closed down by the West Ham defence.
In an action-packed game, West Ham then had strong penalty appeals turned down after Cole was bundled over by Richard Dunne as he chased Keane's long ball. Dunne, the last man back for Villa, made contact just outside the area as Cole was primed to shoot. Referee Mark Halsey looked towards his assistant for guidance but gave nothing.
West Ham kept coming forward and Cole forced a smart near-post save from Friedel after he had been fed by a long pass from O'Neil. Villa thought they had equalised after 23 minutes with a Bent header but it was disallowed by referee Halsey for a push on Jacobsen.
Villa began to enjoy a period ofpossession but West Ham stayed patient in defence, allowing thevisitors to move the ball around without any real penetration. But allthat work was undone when Mark Noble was caught in possession insidethe West Ham box and Villa pounced. Heskey robbed Noble of possessionand Young curled in the cross for Bent, who got in front of WayneBridge and flashed his header past Green.
Firing line: Robbie Keane (left) leads strike partners Victor Obinna and Carlton Cole after hitting West Ham ahead after just two minutes
Bent's goal sparked a key shift in momentum. There was no sense of a street party inside Upton Park now, just nervous tension as Villa started the second period with a new lease of life.
The visitors were only denied the lead by two magnificent saves in quick succession from Green in the West Ham goal. Upson's fluffed header allowed Bent to steal in but his low strike from a tight angle was blocked by Green's one-handed save and the ball shepherded out for a corner.
Cole cleared Collins' powerful header off the line before Noble conceded a careless free-kick on the edge of his own box. Young curled his shot around the West Ham wall but Green was quick to get across and turn the ball behind with a flying finger-tip save.
Grant, who had been forced to replace Manuel Da Costa with Danny Gabbidon in the first half, sent on Zavon Hines for Obinna and then Ba for the injured O'Neil.
Villa remained the more dangerous side. Young flashed a shot across the face of goal and Bent scuffed a golden chance to win the game after being picked out in the box by Walker. West Ham could not create anything meaningful. Hines saw a snapshot blocked by Dunne and Hitzlsperger skied his follow-up effort.
And in the first minute of injury time, Villa finally got their just desserts with Young finding space down the left and picking out substitute Agbonlahor to head home the winner.
West Ham's vice chairman Brady rips into ?5m flop 'big fat Benni'Under-fire manager Houllier handed lifeline by officials at Aston VillaAll the West Ham United FC news, features and opinionAll the Aston Villa FC news, features and opinion
Explore more:People: Darren Bent, Robert Green, Robbie Keane, Gabriel Agbonlahor, Emile Heskey, Matthew Upson, Gary O'Neil, Ashley Young, Lars Jacobsen, Danny Gabbidon, Carlton Cole, Luke Young, Thomas Hitzlsperger, Stiliyan Petrov, Richard Dunne Places: Newcastle, United Kingdom