Having beaten Chelsea on penalties in Sunday's EFL Cup final at Wembley, quadruple-seeking City were not at their usual brilliant best against a West Ham side led by their former manager Manuel Pellegrini.
David Silva hit the post early on but it was substitute Bernardo Silva who came off the bench to win a spot-kick that Aguero converted by sending Lukasz Fabianski the wrong way.
Liverpool's 5-0 victory over Watford at Anfield may have been more emphatic, but City got a result that means they can at least temporarily return to the summit at the weekend as they play before their title rivals.
Despite needing spot-kicks to see off Chelsea three days earlier, City did not look fatigued as they raced out of the blocks and twice came close to scoring in the opening four minutes.
Riyad Mahrez, one of five players brought into the starting XI, lost West Ham debutant Ben Johnson in the box but fired his half volley way over the crossbar before David Silva diverted Kevin De Bruyne's low cross onto a post.
Yet City were unable to keep the pressure on, as Mahrez in particular struggled, with an unsuccessful penalty appeal for handball against Angelo Ogbonna the only other moment of note in the first half.
Samir Nasri's Etihad Stadium return ended at half-time and his replacement, Manuel Lanzini, nearly conjured up the opening goal for the Hammers shortly after arriving.
The Argentinian skipped over compatriot Nicolas Otamendi's outstretched leg and crossed for Andy Carroll, but the former Liverpool striker was denied by Ederson's save.
Pep Guardiola responded by withdrawing the ineffectual Mahrez and Leroy Sane for Raheem Sterling and Bernardo Silva, and it was the latter who won the penalty that Aguero converted to put City ahead.
The Portuguese was driving across the box when Felipe Anderson bundled into the back of him, which resulted in a spot-kick that Aguero stroked into the bottom right-hand corner of the net.
Fabianski dived the wrong way there, but he was equal to efforts from Sterling and Danilo, either side of Ryan Fredericks clearing David Silva's effort off the line, with City's eventual margin of victory only one.
What does it mean? City not at their best but get the job done
This was not a free-flowing attacking masterclass from City, though, in the end, they still ended up with three points. On a night when Liverpool returned to winning ways in style against Watford, City just needed to get the win and remain within a point of Jurgen Klopp's leaders.
Bernardo Silva injects life into City
Guardiola has frequently praised Bernardo Silva this season and he answered the SOS moments after coming on by winning the penalty. The midfielder's energetic running almost produced further goals and City might have been more convincing victors had he started.
Mahrez fails to make an impression
This was Mahrez's first Premier League start of 2019 but Guardiola will be reluctant to hand him too many more opportunities after this poor outing. The Algerian should have relished going up against teenager Johnson, yet his touch was poor and he failed to trouble an isolated full-back, creating zero chances before being withdrawn prior to the hour mark.
KEY OPTA FACTS:
- City have won each of their last seven games against West Ham in all competitions, netting 23 goals while conceding just three.
- West Ham are now winless in their last 18 Premier League away games against 'big six' opposition (D6 L12).
- 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 Manuel Pellegrini (9) than he does any other opposition boss.
City will look to return to the top of the table, and apply pressure on current leaders Liverpool ahead of the Merseyside derby, when they visit Bournemouth on Saturday, with West Ham entertaining Newcastle United later that day.