It was tough going in the early stages, with a well-organised West Ham frustrating City.
With the visitors resolute in defence and industrious in midfield, space was hard to come by and on a couple of occasions, West Ham looked dangerous when they attacked..
But gradually, the champions began to find gaps and create opportunities.
Kyle Walker saw a low drive fizz past the left-hand post and Aymeric Laporte was unlucky to see a header loop just wide.
Mahrez had the ball in the net but the goal was correctly ruled out for offside.
With snow falling continuously, visibility became difficult and it was affecting both teams with the pattern of play slow, and difficult in blizzard-like conditions.
City, however, were adapting and the chances began to tot up until finally, the breakthrough on 34 minutes.
Joao Cancelo played the ball out to Mahrez on the right and the Algerian progressed into the box before sending a short pass into the middle for Gundogan to sweep home.
It was thoroughly deserved by that stage and a couple of minutes later, it could have been two as Gabriel Jesus broke clear only to see his shot scrambled off the line by Ben Johnson.
Mahrez went close again before the break, but the Hammers clung on without conceding again.
The interval allowed the Etihad’s hard-working ground staff to clear the snow and ensure something approaching a normal second period could ensue.
City were quickly on the front foot again and on 56 minutes, Gundogan fed Sterling on the left and his low cross was met by Jesus who just connected ahead of Fabianski, but Aaron Creswell managed to clear before the ball rolled into the net, colliding with the post as he did so.
Then Sterling fed Gundogan inside the box and his low shot was saved by Fabianski as the Blues searched for the goal that would seal three points ten minutes from time.
But finally, the second did come a minute from the end of normal time with a goal made in Brazil as Jesus worked his way into the box from the left before picking out Fernandinho who planted a low shot into the bottom left corner - he'd only been on the pitch a couple of minutes!
There was still time for Manuel Lanzini to pull one back - but the final whistle went straight after as the champions banked three deserved points.