Pedro Obiang's heavily deflected goal was the moment of luck West Ham needed to set them on the way to their first points of the Premier League season as Huddersfield suffered their first defeat.
The Hammers, whose manager Slaven Bilic was under pressure after three successive league defeats, were below par - although the visitors offered little threat.
Javier Hernandez hit the bar in the first half, in one of West Ham's few clear-cut chances.
The breakthrough came in the 72nd minute when Obiang's 25-yard strike hit Mathias Jorgensen's back and looped over keeper Jonas Lossl.
It was the first goal that Huddersfield - or Lossl - have conceded in their first season back in the top flight.
And the second came five minutes later when substitute Andre Ayew - whose introduction for Hernandez was booed by West Ham's fans - turned the ball home from three yards out.
Huddersfield's major opportunity came with 10 minutes left as Thomas Ince hit the crossbar from the edge of the box.