Pep Guardiola's side struggled to find their rhythm in the early exchanges but took the lead in the 30th minute of the contest when Ruben Dias headed a cross from Kevin De Bruyne into the back of the net.
West Ham levelled the scores in the 43rd minute when Michail Antonio found the back of the net from close range, and the Hammers also made an encouraging start to the second period.
David Moyes's side managed to stay in the game despite a lot of pressure from the hosts, but the capital outfit could not find a leveller, with Issa Diop missing a good chance late on, as their Champions League hopes took a hit in Manchester.
The result has moved Man City 13 points clear of second-placed Manchester United at the top of the Premier League table, while West Ham remain fourth, two points clear of fifth-placed Chelsea.
19th min: Half-chance for West Ham at the Etihad Stadium as a deflected cross from Jesse Lingard finds Soucek at the far post - the midfielder heads back towards Antonio, but Ederson does just about enough before Lingard has a strike blocked by Dias.
30th min: Man City make the breakthrough in the 30th minute of the contest as a brilliant cross from De Bruyne is headed past West Ham goalkeeper Darren Randolph by Dias, who managed to free himself from Diop at the far post.
32nd min: A long pass from Kyle Walker frees Mahrez, who appears favourite to beat Randolph to the ball, but the West Ham goalkeeper manages to clear the ball away for a throw.
39th min: Woodwork for West Ham as Antonio collects a cross from Lingard before looking to pick out the bottom corner, but the ball strikes the bottom of the post. The goal might not have stood, though, as Lingard appeared to be offside in the build-up.
43rd min: West Ham level the scores in the 43rd minute of the contest as Antonio turns home from close range after Lingard had met a low cross from Vladimir Coufal. There looked to be a hint of offside about the goal on first viewing but replays showed that the forward was comfortably onside.
55th min: Half-chance for Man City as Walker drives into a shooting position before driving one towards goal, but the ball was always moving wide of the far post.
58th min: Huge opportunity for Man City to regain the lead at the Etihad Stadium as De Bruyne drives into the West Ham box before delivering a dangerous low cross towards Sergio Aguero, but the Argentine just cannot get a touch on the ball.
68th min: Man City regain the lead in the 68th minute of the contest as Stones sweeps the ball into the far corner of the net after meeting a clever cross from Mahrez.
78th min: Man City continue their search for a third goal as Mahrez finds himself outside the West Ham box before striking towards goal, but the attacker's effort is deflected over the crossbar.
94th min: Last-chance saloon for West Ham in Manchester as Lingard delivers a wonderful cross towards Diop, but the centre-back's header drops just wide of the far post.
MAN OF THE MATCH - KEVIN DE BRUYNE
Coufal deserves a special mention for West Ham, but De Bruyne was the standout player on the field. Man City were far from their best on the afternoon, but the Belgium international was again a creative force.
A wonderful cross from the attacker allowed Dias to head past Randolph for the opening goal of the game, while he almost set up Aguero with a low cross in the second half of the contest.
De Bruyne's assist for Man City's opener was just sensational; there did not appear to be much danger for West Ham when the Belgian picked the ball up down the right, but he played a wonderful cross on his weak foot onto the head of Dias, who simply could not pass up the opportunity to net his first goal for the Citizens.
The attacker now has 11 Premier League assists for the season, level with Tottenham Hotspur's Harry Kane.
Possession: Man City 63%-37% West Ham
Shots: Man City 10-9 West Ham
Shots on target: Man City 3-3 West Ham
Corners: Man City 4-2 West Ham
Fouls: Man City 8-11 West Ham
MAN CITY (4-3-3): Ederson; Walker, Stones, Dias, Zinchenko; De Bruyne, Fernandinho, Gundogan (Rodri 89'); Mahrez, Aguero (Jesus 61'), Torres (Foden 65')
WEST HAM (3-4-3): Randolph; Diop, Dawson, Cresswell; Coufal, Soucek, Rice, Johnson (Bowen 84'); Fornals, Antonio (Benrahma 84'), Lingard