Match ends, Manchester City 1, West Ham United 0.
Manchester City needed a second-half Sergio Aguero penalty to see off West Ham and stay one point behind leaders Liverpool at the top of the Premier League.
The defending champions had to wait for the Argentina striker's 59th-minute spot-kick to break down the well-organised Hammers, but ultimately it was enough to secure a vital victory.
City, who are still chasing glory on three fronts after winning the Carabao Cup on Sunday, showed off that trophy before kick-off and tore into the visitors in the opening minutes.
But the closest they came to an early goal was when David Silva turned Kevin de Bruyne's cross on to a post and West Ham soon began to frustrate them.
The Hammers did not threaten at all at the other end until Andy Carroll brought a fine save from Ederson with their first shot of the game at the start of the second half.
However, they succeeded in keeping City quiet and, with Liverpool on their way to a 5-0 win over Watford, the home fans' frustration began to show.
City were utterly dominant on the ball with more than 80% of possession but they needed the introduction of Raheem Sterling and Bernardo Silva off the bench to provide the spark they needed in attack.
Silva took a matter of minutes to make an impact, cutting into the box from the right and going down under pressure from Felipe Anderson, to prompt referee Stuart Atwell to point to the spot.
Aguero made no mistake, sending Lukasz Fabianski the wrong way for his 25th goal of the season
More City chances followed, with Ryan Fredericks clearing off the line from Silva and Sterling missing the target from close range, but in the end one goal was sufficient.
"Many things are going to happen," manager Pep Guardiola said. "I think we are going to drop points and Liverpool are going to drop points so we are going to see, until the end."
Mahrez fails to take chance to impress
With City having lost just one of their past 15 games before taking on West Ham, it is clear there is not much wrong with Guardiola's side at the moment and they coped well enough without the injured Fernandinho here.
One area for concern is the form of Riyad Mahrez, who became City's £60m record signing when he joined from Leicester last summer.
The Algerian has not had many opportunities recently - this was his first Premier League start of the year - but he did not take his chance to impress Guardiola.
Despite being up against a teenage debutant, Ben Johnson, Mahrez struggled to impose himself on the right flank and his final ball, whether a pass or a shot, was frequently disappointing.
It was no surprise when he was replaced by Sterling just 10 minutes into the second half.
Another substitute, Bernardo Silva, replaced Leroy Sane and took Mahrez's place on the right soon afterwards and the pair added much-needed energy to City's flanks, with Silva quickly winning the penalty that Aguero scored.
"Bernardo is a master - an incredible player at reading that situation," said Guardiola.
"Riyad played good - he took some risks and unfortunately he hit the first player often. Normally he is so clinical, such a good player at finishing in the first action with the right foot, but of course sometimes you need time to connect between the players and that is going to happen."
No points for Pellegrini despite game plan
Manuel Pellegrini's City sides were known for their attacking verve but the Chilean demonstrated defensive diligence on his first return to his old club.
The Hammers boss, who took City to the title in 2014, waved to the home fans when they chanted his name in the opening minutes but it was soon clear that he had a plan to frustrate them.
With Pedro Obiang and Declan Rice protecting a solid back four, they sat in their own half and gave City little space to operate in.
When the ball did come near the Hammers area, Issa Diop and Angelo Ogbonna were in the right place to deal with it and of City's 11 shots in the first half, only one was on target.
It took a debatable penalty to end their resistance and, although West Ham are now winless in their past six league and cup games on the road, this was a defensive performance that will offer Pellegrini plenty of encouragement.
"To be generous, it was a little soft, but that is too generous - it was not a penalty," said Pellegrini.
"It was a play that happens a lot of times inside the box - in the other box Manuel Lanzini had exactly the same play and he did not fall to the floor.
"So if we lose this game with another action maybe you can accept it, but not that penalty."
Man of the match - Bernardo Silva (Manchester City)
City extend winning run against Hammers - the stats
- Man City have won each of their past seven games against West Ham in all competitions, netting 23 goals while conceding just three.
- West Ham are now winless in their past 18 Premier League away games against 'big six' opposition (D6 L12).
- City have won 16 of their past 17 home games in all competitions, only losing to Crystal Palace in a league game in December (3-2).
- City striker Aguero has been directly involved in 74 goals (59 goals and 15 assists) in 80 Premier League appearances since Guardiola took over in August 2016 - only Harry Kane has been directly involved in more in that time (87).
- City's Oleksandr Zinchenko has been on the winning side in each of his first 13 Premier League appearances (11 starts), the longest run of wins from the start of a player's career in the competition's history.
- Guardiola has more top-flight league wins against Pellegrini (nine) than he does any other opposition manager.
- Guardiola has won all seven of his meetings with West Ham in all competitions. The only side he has met more often while maintaining a 100% win rate is Malaga, who he has beaten eight times, including four games while they were managed by Pellegrini.
City head for the south coast next, travelling to play Bournemouth on Saturday (15:00 GMT). West Ham are at home to Newcastle later the same day (17:30).
- 17De Bruyne
- 26MahrezSubstituted forSterlingat 55'minutes
- 10AgüeroSubstituted forFodenat 85'minutes
- 19SanéSubstituted forBernardo Silvaat 57'minutes
- 20Bernardo Silva
- 24FredericksBooked at 41mins
- 53JohnsonSubstituted forZabaletaat 63'minutes
- 30AntonioBooked at 87mins
- 18NasriSubstituted forLanziniat 45'minutes
- 8Felipe AndersonSubstituted forDianganaat 76'minutes
- Stuart Attwell
- Shots on Target
Second Half ends, Manchester City 1, West Ham United 0.
Kevin De Bruyne (Manchester City) wins a free kick in the defensive half.
Dangerous play by Andy Carroll (West Ham United).
Offside, Manchester City. Phil Foden tries a through ball, but Kevin De Bruyne is caught offside.
Corner, Manchester City. Conceded by Grady Diangana.
Corner, Manchester City. Conceded by Issa Diop.
Corner, Manchester City. Conceded by Ryan Fredericks.
Offside, West Ham United. Pablo Zabaleta tries a through ball, but Michail Antonio is caught offside.
Michail Antonio (West Ham United) is shown the yellow card for a bad foul.
Kevin De Bruyne (Manchester City) wins a free kick in the attacking half.
Foul by Michail Antonio (West Ham United).
Danilo (Manchester City) wins a free kick in the defensive half.
Foul by Michail Antonio (West Ham United).
Substitution, Manchester City. Phil Foden replaces Sergio Agüero.
Attempt missed. Andy Carroll (West Ham United) header from the centre of the box misses to the left. Assisted by Pablo Zabaleta with a cross.
Attempt saved. Kevin De Bruyne (Manchester City) right footed shot from outside the box is saved in the centre of the goal. Assisted by Ilkay Gündogan.
Attempt missed. Raheem Sterling (Manchester City) left footed shot from the centre of the box is close, but misses to the left. Assisted by Bernardo Silva.
Substitution, West Ham United. Grady Diangana replaces Felipe Anderson.
Corner, West Ham United. Conceded by Vincent Kompany.