Aston Villa might feel they have not seen much of a return on the £9.5m they paid for Charles N’Zogbia in the summer of 2011 but if his contribution to their first win in nine Premier League matches turns out to be the beginning of the end of their relegation fears then perhaps Randy Lerner will feel better disposed towards spending money again.

N’Zogbia, beset by injuries and inconsistent form, had delivered only two top-flight goals in 18 months at the club before yesterday, but it was the French former Wigan forward who brought relief to beleaguered Villa manager Paul Lambert, winning the 74th-minute penalty that Christian Benteke converted to put Villa in front, before curling a delicious free kick beyond the reach of Jussi Jaaskelainen to all but guarantee the points.

Of course, Villa made it difficult for themselves, as they inevitably do. They have made an unfortunate habit of conceding costly late goals in winning positions – Marouane Fellaini’s stoppage-time equaliser after they had led 3-1 at Everton is the latest example – and when Ashley Westwood diverted a Joe Cole cross into his own net with three minutes left, hearts were in mouths.

In the end, they owed as much to Brad Guzan as to N’Zogbia after the American goalkeeper pulled off a point-blank save to deny Kevin Nolan and, from the resulting corner, kept out a header by Carlton Cole.

Lambert, charged with keeping Villa in the Premier League with the players who have threatened to take them down after owner Lerner’s reluctance to spend in January, admitted he was as nervous as anyone. “It’s hard to explain what it is like in the last few minutes,” he said. “The stress levels are ridiculous. But it’s great when it’s finished and you’ve won.

“It was edgy at the end but I thought we deserved it. It’s a massive win and a huge thing for our defence to keep them out at the end. West Ham are a difficult side to play against because of their height and they deserve a lot of credit as they have taken a lot of knocks this year.”

As Villa climbed out of the bottom three for the third time this season, no one was more relieved, you suspect, than Andreas Weimann, who may never miss an easier chance than the one he spurned in the second minute after Jussi Jaaskelainen had allowed a Benteke shot to squirm away from him, doing everything right in positioning himself for the follow-up but somehow sliding the ball wide of the far post with half the goal to aim at.

That moment was still haunting Lambert when Darren Bent, introduced after an hour in place of an ineffective Jordan Bowery, came to Villa’s rescue with a goalline clearance, of all things, to stop Andy Carroll putting West Ham ahead.

Bent’s confinement to the bench had again been a puzzle, given Bowery’s inexperience. When he was given his chance his own contribution might not have been exceptional, but it did seem to prompt a shift in momentum. At that moment, Sam Allardyce’s side were threatening to deepen Villa’s woes and ease their own after a run of one point from seven matches. But then Mark Noble clumsily brought down N’Zogbia and Benteke, confidence high after five goals in his last four matches, stayed cool despite the pressure of the moment, sending Jaaskelainen the wrong way from the spot.

Four minutes later, Bent drew a foul from James Tomkins and N’Zogbia came up with the perfect free kick from a central position, his delivery climbing over the West Ham wall before swinging away out of Jaaskelainen’s reach.

Tourists are limp, leaderless and distinctly UnAustralian

Andrew Grice: Inside Westminster

Blairites be warned, this could be the moment Labour turns into Syriza

The mystery of Britain's worst naval disaster is finally solved - 271 years later

Exclusive: David Keys reveals the research that finally explains why HMS Victory went down with the loss of 1,100 lives

'I saw people so injured you couldn't tell if they were dead or alive'

Nagasaki survivors on why Japan must not abandon its post-war pacifism

The voter Obama tried hardest to keep onside

Outgoing The Daily Show host, Jon Stewart, became the voice of Democrats who felt the President had failed to deliver on his ‘Yes We Can’ slogan. Tim Walker charts the ups and downs of their 10-year relationship on screen