The Hammers survived a late comeback bid while notching an upset over the reigning Premier League champions.
West Ham survived a late onslaught from Manchester City to beat the Premier League champions 2-1 on Saturday.
Goals in each half from Morgan Amalfitano and Diafra Sakho put Sam Allardyce's in-form side in control against an under-par City at Upton Park, only for a brilliant individual effort from David Silva 13 minutes from time to set up a grandstand finish.
Manuel Pellegrini's men threw everything at West Ham in the closing stages, but a stoic rearguard action from the hosts' defense — led superbly by James Collins — ensured West Ham ended a five-and-a-half-year wait for a victory over City.
Allardyce claimed in the buildup that this game represented West Ham's best opportunity to end its 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 start.
Victory means West Ham now sits just one point adrift of second-place City, for whom the result represents a blow in its efforts to keep pace with table-topping Chelsea.
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 back line.
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 4 yards.
Clearly buoyed by the opener, West Ham upped the tempo of its game and could have doubled its advantage on the stroke of halftime, only for Collins to narrowly fail to connect with Amalfitano's low cross after a brilliant set-piece routine.
West Ham picked up where it 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 6 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 cut in from the right and 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.