Most observers had written the Hammers off before kickoff, but the relegation-threatened visitors went into half time with a deserved lead courtesy of Angelo Ogbonna's header right on the stroke of the interval.
City were far from their free-flowing best but, having scored late winners in their last three matches against Feyenoord, Huddersfield Town and Southampton, the Premier League leaders again struck in the final 10 minutes through David Silva to keep their remarkable winning run alive.
In addition to equalling the Premier League record of 13 consecutive wins - which restores their eight-point lead at the top of the table - City have now emerged victorious from their last 20 games across all competitions.
City had seen their lead cut to five points when Manchester United beat Arsenal on Saturday evening, but it was a West Ham side ravaged by injuries that had the brightest attacking moments in the opening quarter of the game.
The best chance of the early exchanges arrived for the visitors after just seven minutes when Cheikhou Kouyate flicked the ball onto the back post from a corner, but Michail Antonio could not turn it home at full stretch.
The home side were lethargic with the ball at their feet, though, and it took until the 25th minute for Adrian - in goal in place of ineligible City loanee Joe Hart - to be called into action when he tipped Silva's deflected effort over the crossbar.
Raheem Sterling sliced a left-footed shot well off target moments later, but the best openings continued to arrive for the visitors and Manuel Lanzini stung the palms of Ederson from a tight angle with 10 minutes of the first half remaining.
West Ham's belief continued to grow against their complacent hosts, and David Moyes's side took a shock yet deserved lead in the final minute of the first half when Ogbonna met Aaron Cresswell's cross with a firm header which Ederson could not keep out.
City posed more of an attacking threat as a result and levelled things up shortly before the hour mark when Nicolas Otamendi smuggled Jesus's low ball into the back of the net from close range, moments after Kevin De Bruyne had seen a powerful free kick parried away by Adrian.
The goal finally sparked the league leaders into life, but West Ham did a good job of limiting them to long-range efforts as Leroy Sane, De Bruyne and Silva all either failed to hit the target or were denied by Adrian in the space of just 10 minutes.
City should have taken the lead with just under 20 minutes remaining, though, as Adrian pulled off a fine one-handed stop to deny Jesus from just outside the area before Sterling fluffed his lines from the rebound with the goal gaping.
Silva and Jesus were the next to threaten the West Ham goal as City again entered the final 10 minutes needing a late winner, although they were almost stung at the other end when the visitors made a rare break forward and Antonio forced Ederson into a flying save.
City have been the undisputed kings of late goals this season, though, and they did it again with seven minutes remaining when Silva hooked an acrobatic volley back across goal and into the far corner after being picked out by a sumptuous pass from De Bruyne.
West Ham almost spoiled the party in the final minute of normal time when Marko Arnautovic got the better of Mangala and pulled the ball back for Diafra Sakho, but the striker fired his first-time effort narrowly wide of the target when he should have done better.
As it was, Moyes was left still searching for his first win as West Ham boss as his side remain 19th in the table and three points from safety, although the former Manchester United manager will be able to take plenty of positives from this performance going into a daunting double-header against Chelsea and Arsenal in their next two games.
City, meanwhile, take on United at Old Trafford next weekend when they could extend their lead to 11 points should they rack up a 14th consecutive league win, which would equal the all-time Premier League record set by Arsenal over two seasons.
This win sees them draw level with Arsenal's class of 2001-02 and Chelsea from last season as the only teams to have won 13 games on the bounce in a single Premier League campaign, extending their best-ever start to a season in the process.
Manchester City (4-3-3): Ederson; Walker, Otamendi, Mangala, Danilo (Jesus, 45'); Delph, De Bruyne, Silva; Sterling, Sane (Bernardo, 93'), Aguero (Fernandinho, 85')
West Ham United (3-5-1-1): Adrian; Cresswell, Zabaleta, Ogbonna, Masuaku; Rice, Kouyate (Sakho, 43'), Obiang; Fernandes, Antonio (Ayew, 88'), Lanzini (Arnautovic, 69') body check tags ::