Manuel Pellegrini’s second-placed team had hoped to close the gap on the Blues to two points ahead of their rivals’ clash with Manchester United on Sunday.
But West Ham maintained their impressive recent form to stun the visitors, who were beaten in the league for the second time this season following their loss to Stoke in late August.
Morgan Amalfitano opened the scoring in the 21st minute and Diafra Sakho added the decisive second goal in the 75th minute.
David Silva set up a tense finish when City’s Spanish forward scored a fine individual effort two minutes later, but fourth-placed Hammers held on for a fourth win in their last five matches.
“We had a lot of chances to score but it is difficult to win if you don’t take them,” Pellegrini said.
“I don’t think it was a fault of our team for the performance in the first half, it was more about the intensity of West Ham and you must credit them for that.
“We are just starting the season, we have 80 points left to play for. So it is early.
“We will continue fighting because there is no title being handed out at the moment.”