Match ends, Manchester United 2, West Ham United 1.
West Ham manager Manuel Pellegrini said he is "sure" his side would have beaten Manchester United at Old Trafford had VAR been in place.
An under-par United won thanks to two Paul Pogba penalties, returning to winning ways after back-to-back defeats.
But the decision to award United their first penalty - when Robert Snodgrass was deemed to have fouled Juan Mata - was contentious, and West Ham should have taken the lead in the ninth minute but Felipe Anderson's goal was incorrectly ruled out for offside.
Pellegrini also said United's second penalty should not have stood because Anthony Martial, who was fouled by Ryan Fredericks, was offside in the build-up - although replays seemed to show he was onside.
"I am not complaining about the referee because they were not big mistakes, difficult mistakes, but with technology we have a different score," Pellegrini said.
"With VAR, I am sure we would win the game 1-0.
"Felipe Anderson was onside. It was not a penalty from Robert. The last goal from Man Utd was offside, the last pass."
The Hammers deservedly equalised through Anderson shortly after half-time, when he converted Manuel Lanzini's cross at the back post and Michail Antonio twice came close to putting Pellegrini's side 2-1 in front.
First he smashed a shot from the edge of the box off the crossbar and minutes later had a header excellently saved by David de Gea.
United manager Ole Gunnar Solskjaer admitted his side "got away with it".
"They played better than us, it is fair to say, I don't think anyone will disagree," he added.
"Sometimes you get more than you deserve and today is one of those nights."
The win sees United climb to fifth, two points behind fourth-placed Chelsea who play Liverpool on Sunday, while West Ham stay 11th.
Fortune favours Man Utd in important win
With the second leg of their Champions League quarter-final against Barcelona to come on Tuesday, Solskjaer made five changes to his team and for much of the game they lacked fluidity, giving the ball away repeatedly in the first half in particular.
They should have fallen behind early when replays showed Diogo Dalot played Anderson onside.
For the first penalty, Snodgrass rushed back to prevent Mata shooting from the edge of the penalty area and did not get to the ball with his challenge. But there was to be little contact with the Spaniard either, who appeared to kick his own heel as he went down.
West Ham were the better side in the first half and overcame a good United spell following the introduction of Marcus Rashford, to shade the second.
Had Antonio put away either of his chances then few would have argued the Hammers deserved to lead.
There was little doubt around the foul for United's second penalty, when Martial got in behind the defence and Fredericks brought him down when making a last-ditch attempt to deny the Frenchman a shot.
Pellegrini, however, complained that Martial was offside because he ran on to a flick by Rashford - but replays did not show any touch by the England international, meaning Martial was onside from the original pass.
Pogba calmly converted the penalty, as he had done with the first, to ensure United won for just the second time in their past six games.
With Barcelona to come on Tuesday and Premier League games against Everton, Manchester City and Chelsea to follow, it could prove to be an important victory in the race for the top four.
"[We were] lucky it wasn't Barcelona but West Ham played well, played better than us," Solskjaer said.
"We have one of the best goalkeepers in the world. That save is unbelievable.
"He won us the game because at 2-1 we would have struggled to create enough.
"We got away with it, got three points. In a few years no-one will remember how we played if we finished in the top four."
West Ham's good work to no avail
West Ham's inconsistency has held them back this season, with wins over Manchester United and Arsenal earlier in the season often followed by poor performances like those in their three defeats in their past four games.
At Old Trafford on Saturday they impressed with Declan Rice excellent in midfield, and Anderson and Lanzini threatening in attack.
Lanzini, who has been restricted to just six starts this season due to injury, went off with what appeared to be a groin problem in the second half, but the introduction of Antonio almost immediately paid off.
Pellegrini furiously protested at the disallowed goal and the penalty decision in the first half. His side, who are in 11th place with 42 points, were unfortunate.
He must, however, take pride in the performance despite a third successive defeat.
"We had the possession and the chances of the game but you need a bit of luck to win the games," the Chilean said.
"It is more difficult to finish in the European places but my target is to finish as high as we can and we will fight to the last day to achieve that.
"Playing like we did today will make it easier.
"It was a pleasure to see the team playing the way we did against Man Utd in their own stadium."
Man of the match - Paul Pogba (Manchester United)
Pogba's best season - the key stats
- Manchester United are unbeaten in 14 Premier League home games (W9 D5) since a 3-0 loss against Spurs in August. Only Liverpool (37) and Arsenal (16) are currently on longer unbeaten runs at home in the competition.
- West Ham are winless in their last eight Premier League away games (D1 L7), losing the last four in a row.
- United are unbeaten in their last 11 Premier League home games against West Ham - among current Premier League sides, they are only currently on a longer such run against Arsenal (12).
- United have won a league-high 12 Premier League penalties this season. Indeed, it's also the most the Red Devils have ever taken in a single campaign in the competition.
- West Ham had 18 shots in this match, their most in a Premier League away game since December 2016 (24 vs Leicester).
- Paul Pogba has scored seven Premier League penalties this season - only Ruud van Nistelrooy in 2002-03 (8) has scored more from the spot for United in a single season.
- Pogba has been directly involved in 22 Premier League goals this season (13 goals, 9 assists), his best return in a single campaign in the top five European leagues.
- Felipe Anderson scored his first Premier League goal in 14 games, becoming the first West Ham player to score home and away against United in the same league season since Jermain Defoe in 2001-02.
Manchester United travel to Barcelona for their Champions League quarter-final second leg on Tuesday (kick-off 20:00 BST), looking to overturn their 1-0 first-leg deficit.
Their next league game is away against Everton on Sunday, 21 April at 13:30.
West Ham host Leicester in their next game on Saturday, 20 April (kick-off 15:00).
- 1de Gea
- 16RojoSubstituted forPereiraat 75'minutes
- 8MataBooked at 34minsSubstituted forRashfordat 55'minutes
- 9LukakuSubstituted forGreenwoodat 75'minutes
- 5ZabaletaSubstituted forFredericksat 76'minutesBooked at 79mins
- 8Felipe Anderson
- 10LanziniSubstituted forDianganaat 62'minutes
- 17HernándezSubstituted forAntonioat 73'minutes
- Graham Scott
- Shots on Target
Second Half ends, Manchester United 2, West Ham United 1.
Michail Antonio (West Ham United) wins a free kick in the attacking half.
Foul by Chris Smalling (Manchester United).
Foul by Robert Snodgrass (West Ham United).
Fred (Manchester United) wins a free kick in the defensive half.
Delay over. They are ready to continue.
Delay in match Phil Jones (Manchester United) because of an injury.
Corner, West Ham United. Conceded by Diogo Dalot.
Mark Noble (West Ham United) wins a free kick in the defensive half.
Foul by Jesse Lingard (Manchester United).
Attempt blocked. Grady Diangana (West Ham United) left footed shot from the centre of the box is blocked. Assisted by Michail Antonio.
Attempt blocked. Felipe Anderson (West Ham United) header from the left side of the box is blocked. Assisted by Robert Snodgrass with a cross.
Corner, West Ham United. Conceded by Andreas Pereira.
Goal! Manchester United 2, West Ham United 1. Paul Pogba (Manchester United) converts the penalty with a right footed shot to the bottom left corner.
Ryan Fredericks (West Ham United) is shown the yellow card for a bad foul.
Penalty conceded by Ryan Fredericks (West Ham United) after a foul in the penalty area.
Penalty Manchester United. Anthony Martial draws a foul in the penalty area.
Corner, West Ham United. Conceded by David de Gea.
Attempt saved. Michail Antonio (West Ham United) header from the centre of the box is saved in the top left corner. Assisted by Grady Diangana with a cross.