Fredi Kanoute's 65th minute equaliser may still prove priceless but, after he had set up Trevor Sinclair for the 15th minute opener, Hammers relinquished their early grip and allowed Villa back into it with a Darius Vassell penalty needlessly conceded by Tomas Repka 10 minutes before half-time.
The visitors, just seven points ahead of their hosts and facing a tough-looking run-in, were on top by the time substitute Oyvind Leonhardsen gave them the lead eight minutes into the second half. And to underline the see-saw nature of this relegation battle, the Norwegian should have made it 3-1 just seconds later.
But having been let off the hook, West Ham proceeded to waste several clear-cut chances in a nerve-wracking second half.
To be fair, it was a combination of poor finishing and the brilliance of keeper Peter Enckelman that deprived Hammers of a vital win.
Enckelman produced two brilliant one-handed saves in the space of a minute to deny Glen Johnson's drive towards the near-post and a Kanoute header. He also cleared another Kanoute close-range shot with his boot as Villa defended for their lives.
As if that were not enough, the Villa keeper possibly saved his best until last - flying off his line in time added on to block Jermain Defoe's goalbound strike. His blunders in the Birmingham derby matches seemed a distant memory as he became Villa's hero.
Defoe, who fired high and wide to miss two decent chances in the first half, went closer in the second. Apart from that late heroic save by Enckelman, the young England Under-21 striker blazed another shot over the bar with his weaker left foot.
Defoe was cursing and kicking the ground in frustration, but he should not shoulder all the responsibility for the failure to secure three points. Les Ferdinand, who made way for the recall of Kanoute, was summoned from the subs' bench (for the ineffective Lee Bowyer) soon after Villa went ahead and immediately caused concern for the visitors' back three, winning many headers and typically competing for everything in a three-pronged attack with Defoe and Kanoute.
When Lomas - whose header hit the upright in the first chance of the game - rolled an inviting pass to Ferdinand, unmarked 15 yards out, the fans behind the Bobby Moore Stand goal held their breath waiting for the net to bulge....only for Ferdi to blaze his shot agonisingly into row F.
Glenn Roeder also turned to Don Hutchison for inspiration but it was no gung-ho substitution. Instead of sacrificing the leg-weary Lomas, it was Kanoute who was withdrawn. All speculation about his future put on hold, the Frenchman's skill and pace put him in down the right flank before supplying the cross from which Sinclair slammed home the first goal.
And when Joe Cole, again the top Hammer in a brilliant all round display of sheer endeavour laced with sublime touches, picked him out with the ball of the game, Kanoute did the business with a silk touch and clinical left-footed finish.
It should have been the prelude to a winning finale but the missed chances will cause still more sleepless nights for the claret and blues of East London, if not Birmingham.
Glenn Roeder said: ''I don't think our players could have given any more and with the chances we created, we should have taken all three points. Even allowing for Villa's chances, we still created more than them - Jermain could have had a hat-trick off his left foot alone.
''Having said that, Enckelman was excellent in goal for them - and he needed to be today. I feel we've let Aston Villa off the hook. We've dropped two points here.
''The least said about the penalty the better. I thought Allback was backing in (to Repka) and went down too easily. It threw Villa a lifeline and gave them encouragement to be positive.
''It's a waste of energy talking about how many points we're going to need. Who knows? Just take each game as it comes. It's important that we go to Bolton and defend well and give our forwards the chance to win the game."
Minute-by-minute:
1 - The first shot of the game goes to Aston Villa, as Hadji hooks an effort over his shoulder from the edge of the box, but the ball thankfully sails over the bar.
9 - Hammers go close to opening the scoring, as Cole's corner is met by Lomas, whose looping header beats Enckelman but rebounds off both crossbar and post before dropping into the grateful arms of the Villa keeper.
13 - Another extremely close call, as a lofted ball over the top releases Defoe, whose first touch takes him slightly away from goal. The young striker regains his balance, though, and fires a left-footed shot just inches past the post.
15 - GOAL! After two near misses, it's third time lucky for Hammers, as Trevor Sinclair opens the scoring. Kanoute's rampaging run down the right ends with an excellent cross that is flicked on to the far post, where Sinclair is waiting to chest down and fire underneath the body of Enckelman from 10 yards out. West Ham United 1 Aston Villa 0.
26 - Substitution for Aston Villa, Gudjonsson replaces Hendrie.
27 - Villa almost grab an equaliser, as a corner from the right is met by Hadji, whose header only just clears the crossbar, to the relief of a static James.
30 - Repka booked for foul on Vassell.
35 - As a long ball is flighted into the Hammers box, Repka appears to push Allback in the back in an attempt to win the header and the Swede doesn't need any more encouragement to go down. Referee Dean immediately points to the penalty spot.
36 - GOAL. Vassell plants the ball low to James' right from 12 yards out to bring the scores level. West Ham United 1 Aston Villa 1.
38 - Bowyer booked for foul on Barry.
39 - Sinclair collects Kanoute's pass in the box and turns well before firing in a low cross that is deflected over for a corner before it can reach the unmarked Johnson.
40 - From Bowyer's resulting corner, Pearce climbs high to head just wide from eight yards out.
41 - Lomas booked for dissent.
43 - A neat move appears to have released Vassell, but Johnson gets across superbly to block the effort.
45 - Hitzlsperger's fierce right foot shot is well palmed out by James. Allback appears to be on hand to poke home the loose ball, but thankfully an offside flag denies him and James again saves the effort anyway.
45 - Defoe turns well in the box, but fires his left-footed shot over the bar from 12 yards out.
Half-time: West Ham United 1 Aston Villa 1.
Second Half:
49 - Hammers start the second half in determined mood and go close to restoring their lead when Johnson heads down a Bowyer corner and Kanoute fires goalwards, only for Enckelman to save with his legs.
52 - Substitution for Aston Villa, Leonhardsen replaces Hadji.
53 - Barry booked for foul on Lomas.
53 - GOAL. Upton Park is stunned into silence as Villa take the lead. A sliced clearance by James is collected by Barry, who races into the area and clips the ball to the far post, where Leonhardsen is unmarked to tuck the ball home with his first touch of the game. West Ham United 1 Aston Villa 2.
55 - Villa almost add a third in identical fashion. This time Vassell skips down the left and crosses to the far post, but Leonhardsen thankfully fires his second touch of the game over the bar.
57 - Pearce and Repka are now looking decidedly disjointed and Allback goes close when he collects a loose ball 25 yards out and fires in a low left-foot shot that James tips round the post.
59 - Vassell again wriggles free on the left and releases Samuel, who cuts inside two defenders and fires a shot
62 - Substitution for West Ham, Ferdinand replaces Bowyer.
65 - GOAL! Hammers get back into it, as Cole's superb pass from the centre circle picks out the run of Kanoute, and the Frenchman lifts the ball over a defender before volleying left-footed under Enckelman. West Ham United 2 Aston Villa 2.
77 - Hammers are denied twice in the space of a minute by the reflexes of Enckelman. First the Villa keeper pulls off a stunning save from Johnson's fierce effort after Sinclair had released the youngster, then, from the resulting corner, he somehow manages to tip Kanoute's goalbound header over the bar.
78 - Ferdinand is guilty of a glaring miss, as he fires Lomas' inviting cut-back over the bar from 12 yards out.
84 - Cole booked for foul on Hitzlsperger.
85 - Substitution for West Ham, Hutchison replaces Kanoute.
88 - Another moment of agony, as Sinclair's pass is dummied by Hutchison and reaches Defoe, who turns and finds a yard of space, but blasts his shot over the bar.
Added time: 3 minutes.
90 - Defoe looks like winning it with a magical turn in the centre circle and drive into the box, but his effort is blocked by Enckelman and the Villa keeper then collects the rebound.
90 - Substitution for Aston Villa, Taylor replaces Allback.
Full time: West Ham United 2 Aston Villa 2.