Aston Villa's hopes of Premier League survival received a major boost as two quick-fire goals saw off West Ham and moved them out of the bottom three.
After a poor first half, the hosts went ahead through Christian Benteke's penalty after Mark Noble clumsily fouled Charles N'Zogbia.
N'Zogbia doubled the lead moments later, curling in a 20-yard free-kick.
Ashley Westwood's late own goal set up a tense finale, but the hosts held on to the relief of the Villa Park crowd.
However, Paul Lambert's men needed two injury-time saves from goalkeeper Brad Guzan, denying Kevin Nolan and Carlton Cole, before they could celebrate their first Premier League win since the 3-1 victory at Liverpool on 15 December.
With bottom six rivals Queens Park Rangers, Wigan, Reading and Newcastle all losing on Saturday, Villa knew they would climb up to 17th place with a first success in nine league games.
But they had to survive a nervy final few minutes as West Ham piled on the pressure against a team that surrendered a two-goal advantage at Everton last weekend.
Villa boss Lambert had sprung a surprise in his line-up as, with striker Gabriel Agbonlahor absent through illness, he handed a first Premier League start to 21-year-old Jordan Bowery, a £500,000 summer signing from League Two Chesterfield.
It meant £18m club record signing Darren Bent, who had only played 79 minutes of Premier League football since November, was again left on the bench.
Villa, who had only scored twice in their previous seven home Premier League games, would have been in front inside two minutes but for an horrendous miss by Andreas Weimann.
Benteke cut in from the left wing and saw a powerful shot parried by Hammers goalkeeper Jussi Jaaskelainen. The ball fell to the unmarked Weimann six yards out but the Austrian, who made his first start for his national side in the week, pushed his effort beyond the far post.
For a long time, it looked as though Weimann's miss could prove costly as West Ham upped the tempo in the second-half and posed a greater attacking threat.
Ciaran Clark and Ron Vlaar blocked goal-bound chances, before Lambert replaced the ineffective Bowery with Bent, who was immediately involved in the action.
It was not, however, in the manner expected as the Villa striker cleared Andy Carroll's attempt off the goal-line with his first touch of the match.
The hosts finally took hold of an ugly game when N'Zogbia was adjudged to have been fouled in the area by Noble.
Benteke kept his composure to send Jaaskelainen the wrong way with the spot-kick for his 15th goal of the season, and the home fans had barely stopped celebrating before Villa doubled their lead, N'Zogbia curling a wonderful free-kick into the top corner.
Villa, who also threw away a two-goal lead against West Brom last month, faced an anxious final five minutes after Joe Cole's cross looped off Westwood's head and over a backpedalling Guzan.
West Ham almost snatched a point at the death but Guzan made two crucial saves from Nolan and Cole as Villa held on for the victory.
West Ham manager Sam Allardyce:
"Apart from the Aston Villa fans, anyone who watched this afternoon knows we deserved something.
"The sad thing is, after not converting our chances, we have paid the price by conceding from a free-kick and a penalty.
"Apart from Jussi Jaaskelainen spilling an early shot which fell to Weimann, Aston Villa created and contributed nothing.
"We were waiting to see what Villa had to throw at us in the first half and we coped with that. Then our plan was to go at them in the second half and we created chance after chance.
"We completely dominated the second half and we've ended up losing 2-1. Even at the end their goalkeeper was the hero."