Diafra Sakho's header gave Sam Allardyce's men a deserved victory over the Premier League champions, who paid for a sluggish start after their Champions League exertions
Goals in each half from Morgan Amalfitano and Diafra Sakho put Sam Allardyce's in-form side in control against an below-par City, only for a brilliant individual effort from David Silva on 77 minutes to set up a grandstand finish.
Manuel Pellegrini's men threw everything at West Ham in the closing stages, but a heroic rearguard action - marshalled superbly by James Collins - ensured West Ham ended a five-and-a-half-year wait for a victory over City.
The result means West Ham now sit just one point adrift of second-placed City, for whom the result represents a blow in their efforts to keep pace with table-topping Chelsea.
Allardyce claimed in the build-up that this game represented West Ham's best opportunity to end their winless run against City, due to the combination of his team's good form and the champions' midweek exertions in Europe, when Pellegrini's side drew 2-2 at CSKA Moscow.
And so it proved, as City struggled to cope with West Ham's energetic pressing game - exemplified by nobody better than on-loan Barcelona midfielder Alex Song, who was outstanding throughout.
It was no surprise when Allardyce named an unchanged XI from last week's 3-1 win at Burnley, and the hosts - who have now lost just one of their last six Premier League games - looked full of confidence from the off.
Unsurprisingly, it was Sergio Aguero who provided City's early attacking threat, with the elusive Argentinian dropping deep to run directly at the heart of West Ham's backline.
The likes of Silva and Yaya Toure were struggling to assert their usual influence for City, though, and West Ham were rewarded for their solid start when Amalfitano rounded off a superb team move after 21 minutes.
Much has been made of Allardyce's excellent business in the transfer window, and it was three of his new recruits who combined to break the deadlock after 21 minutes.
The impressive Enner Valencia showed his searing pace in latching onto a perfectly weighted pass from Song down the right, before cutting back for Amalfitano to convert from no more than four yards.
Clearly buoyed by the opener, West Ham upped the tempo of their game and could have doubled their advantage on the stroke of half-time, only for Collins to narrowly fail to connect with Amalfitano's low cross after a brilliant set-piece routine.
West Ham picked up where they left off after the break, with Stewart Downing and Sakho threatening Joe Hart's goal.
But, as the home side's intensity inevitably dropped, City - and Aguero and Toure in particular - sparked into life.
Aguero forced Adrian into a superb save on the hour, before inexplicably missing the visitors' best chance of the game, as he struck the bar from six yards after Toure's driving run through the middle ended with Jesus Navas cutting back to the striker.
Toure himself then rattled Adrian's bar, and that narrow miss proved costly as Sakho headed home his sixth Premier League goal of the season from Aaron Cresswell's deep cross to seemingly give West Ham an unassailable lead with 15 minutes to go.
Silva had other ideas, though, as he jinked in from the right, beat four West Ham defenders before curling an unstoppable shot beyond Adrian from 18 yards.
City laid siege to Adrian's goal thereafter, with Toure firing into the side-netting in the 90th minute and Stevan Jovetic forcing the goalkeeper into another save, but West Ham held firm to secure a deserved three points.