The Hammers picked up their first points of the season and alleviated some pressure on their under-fire boss as Huddersfield were beaten for the first time since being promoted to the Premier League.
The rain was coming down in stair rods at the London Stadium which undoubtedly made conditions harder for both sets of players.
It was the home side who started brightly, creating a number of good chances in the opening few minutes. Andy Carroll smashed the ball across the area but it was just out the reach of an outstretched Cheikhou Kouyate and Javier Hernandez uncharacteristically crashed a shot against the bar from close range after good work from Michail Antonio.
Antonio’s pace was causing problems down both flanks for the Huddersfield defence as Joergensen picked up a booking for bringing him down on the left and the winger saw a curling effort deflected over the bar after cutting in from the right.
Kouyate had a great chance to give his side the lead in the closing stages of the first half after a cross from Antonio was headed towards him at the edge of the box, but he miscued his shot terribly under little pressure.
The second half started quietly, with West Ham still on top but unable to create many guilt-edged chances.
Kouyate went close after turning his marker in the box but he fired just wide for the hosts.
Huddersfield had probably their best chance to open the scoring when Aaron Mooy received the ball around 25 yards out, but his long range effort sailed over the bar.
The Hammers finally opened the scoring after 72 minutes and it involved a large element of luck. A shot from Pedro Obiang on the edge of the box took a huge deflection off the back of Mathias Joergensen and looped over the wrongfooted Jonas Lossl in the Huddersfield goal and went in off the post. Judging by Bilic's celebrations he won't care about the fortuitous way in which his side took the lead.
Minutes later the lead was doubled by substitute Andre Ayew, whose introduction had been greeted with mixed reception when he replaced Hernandez after 64 minutes. A dangerous corner by Aaron Cresswell was flicked on by Jose Fonte and the Huddersfield defenders failed to clear, allowing Ayew to slide in and finish from close range.
The two quickfire West Ham goals sparked Huddersfield into life, and they had two opportunities of their own in quick succession. Steve Mounie forced Joe Hart into a smart save with his effort from 20 yards out, before Tom Ince's curled effort from inside the box hit the crossbar after a slight deflection.
After the initial Huddersfield pressure, the home side were able to see out the final few minutes in relative comfort and secured an important three points for Slaven Bilic on the manager's birthday.
The Croatian manager was under significant pressure after West Ham lost their first three games but the convincing victory will relieve that pressure significantly at this early stage of the season.
Terriers boss David Wagner will be disappointed with his side's performance, with them conceding for the first time in the Premier League and rarely threatening Joe Hart in goal until the latter stages, and this defeat will take little bit of the shine off of his side's overwhelmingly positive start to the season.