The Terriers looked like becoming the first promoted team in Premier League history to begin a season with four clean sheets, but Pedro Obiang and Andre Ayew both scored within the space of five minutes to break their hearts.
West Ham were on top in their first home match of the campaign but, after Chicharito had hit the bar in the first half, took until the 72nd minute to score. Ayew passed to Obiang, whose shot from distance deflected in off Zanka.
It quickly became 2-0 as substitute Ayew reacted quickest when Aaron Cresswell's corner took a touch off Jose Fonte.
Tom Ince hit the bar for Huddersfield, who pushed late on, but West Ham stayed strong to give manager Slaven Bilic a perfect winning birthday present.