The Hammers moved into a two-goal lead in Romford but James Wilson's penalty reduced the arrears and sparked hopes of a dramatic late comeback.
United were puzzled when Ashley Fletcher converted a free-kick by Sean Goss and the goal was inexplicably disallowed by the match officials. To add to the frustration, Lewis Page opened the scoring with three minutes remaining of the first half following a one-two and slipped his finish under Joel Castro Pereira.
Devonte Redmond and Nicholas Ioannou were denied during a goalmouth scramble before the hosts doubled the advantage through Jerry Amoo with a volleyed finish.
With time running out, a handball inside the box allowed last season's top goalscorer Wilson to drill low past Vit Nemrava from the spot. However, Steve Potts' East Londoners held on to clinch the three points with United next in action away to Stoke City next weekend.
United: J.Pereira; C.Evans, Borthwick-Jackson, Ioannou (Riley 72), Barber (Thompson 72); Harrop, Willock, Goss, Redmond (Mitchell 72); Fletcher, Wilson. Subs not used: O'Hara, Croskery.