Manchester United needed two Paul Pogba penalties to return to winning ways with a laboured victory over West Ham at Old Trafford.
The Frenchman converted after Robert Snodgrass was deemed to have fouled Juan Mata in the first half and when Ryan Fredericks brought down Anthony Martial in the 80th minute.
But West Ham were the better side for large parts of the contest.
They should have taken the lead in the ninth minute when Felipe Anderson’s effort was incorrectly ruled out for offside, before the Brazilian deservedly equalised shortly after half-time by converting Manuel Lanzini’s cross at the back post.
With the score at 1-1, Michail Antonio smashed a shot from the edge of the box off the crossbar and had a header excellently saved by David de Gea.
The win sees United, who had lost their last two games, climb to fifth, two points behind fourth-placed Chelsea who play Liverpool on Sunday.
With the second leg of their Champions League quarter-final against Barcelona to come on Tuesday, United manager Ole Gunnar 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.
The hosts were lucky not to go behind early on when replays showed Diogo Dalot played Anderson onside and there was also contention around the awarding of United’s 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, which came within minutes of him being sent on from the bench, then not many would have argued the Hammers had not deserved to lead.
But there was little doubt about 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.
Pogba calmly converted, 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.
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.
Manager Manuel Pellegrini furiously protested at the disallowed goal and the penalty decision in the first half and his side were unfortunate.
He must, however, take pride in the performance despite a third successive defeat.