West Ham had the better of the opening exchanges and would have been aggrieved to have a goal wrongly ruled out for offside in the 10th minute through Javier Hernandez.
United were awarded a penalty in the 17th minute after Robert Snodgrass brought Juan Mata down with a clumsy challenge just inside the box. Paul Pogba struck the spot-kick down the middle and in to the back of net to break the deadlock.
The Hammers came close to equalising in the 25th minute. Snodgrass whipped his corner into the far post where the Brazilian was waiting and flicked it on towards goal, but it was just off target.
Two minutes later, Pogba had a good chance to grab a second. Romelu Lukaku picked up the ball on the left wing and cut the ball back to Pogba who had just made the run into the box. Instead of hitting the shot first time though, he set himself which allowed Zabaleta to get across and block the effort.
With five minutes to go before the interval, a sloppy back-pass from Mark Noble found Anthony Martial who played a quick throughball to Lukaku, who made the run into the box before getting his shot away, but his effort was blocked and put out for a corner.
The visitors equalised in the 49th minute. They won back possession from a sloppy David de Gea throw with the ball finding its way on the left-hand flank to Manuel Lanzini, who did well to create a space and deliver the ball to the back post where Felipe Anderson was totally unmarked and side-footed the ball in to the near post with De Gea getting a touch to the ball on its way in.
Five minutes after netting the equaliser, Pablo Zabaleta had a decent attempt on goal. Chris Smalling headed a cross out to the edge of the box where Zabaleta was waiting but his left-foot volley was slightly on the tame side, allowing De Gea to make the save.
Red Devils boss Ole Gunnar Solskjaer brought Marcus Rashford on for Mata in search of an equaliser and he almost made an immediate impact. Smalling won the ball back in midfield and played a lovely through ball for Rashford, who struck the ball first time across goal but was denied by an excellent save from Lukasz Fabianski. Rashford then had another good opportunity in the 63rd minute but headed a bouncing ball over from point-blank range.
West Ham were pinning United back in their own half and causing them a lot of problems. Michail Antonio went on a brilliant individual run, shugging off several defenders but unluckily hit the crossbar with a sweetly-struck left-footed effort.
Two minutes later, Antonio was denied again, when he got on the end of Snodgrass's cross and headed the ball down in to the ground but was thwarted by a world-class save from De Gea, who managed to tip the ball over the crossbar.
Soon after, the Solksjaer's side won a penalty after Martial was one-on-one with the keeper before being hacked down by Ryan Fredericks, who was perhaps lucky to escape with just a yellow card. Pogba dispatched the spot-kick in to the bottom-right corner. With no further clear-cut opportunities created, that would ultimately be the killer blow as United ran out 2-1 winners.