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 comfortably ahead against 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.