Lingard, who enjoyed a loan spell at West Ham last season, came off the bench to grab the winner with a minute remaining.
The result sees United climb to second place in the table while David Moyes’ team are in eighth position.
Before kickoff, both sets of players, coaches and supporters gave a minute’s applause in memory of former West Ham and England striker Jimmy Greaves, who died on Sunday aged 81.
A minute later, West Ham went up the other end and opened the scoring after Benrahma’s shot from outside of the box deflected in off Raphael Varane.
It only took five minutes for United to grab an equaliser when Ronaldo tapped home from close range after Fabianski had spilled his initial flick from Fernandes’ cross.
Both sides had good chances to go ahead before the break but Fabianski saved from Ronaldo while Nikola Vlasic missed the target from inside the area.
Ronaldo almost grabbed his second a minute into the second half but Fabianski raced out and denied him with a great save.
However, with a minute remaining, Lingard stepped up with a stunning curling strike to put the visitors ahead.
But in stoppage-time, West Ham were awarded a penalty after a VAR review when the ball struck Luke Shaw‘s hand inside the box.
Noble was brought on to take the penalty but his spot kick was saved from De Gea to rescue the three points for United.