West Ham rarely looked convincing. City's Oleksandr Zinchenko intervened when Manuel Lanzini was through at the other end, before Ederson had little trouble gathering the ball from record signing Sebastien Haller's attempted overhead kick.
It was only a matter of when City, with off-season signing Rodri looking assured in midfield, would increase the tempo and make more of their superiority.
Kevin de Bruyne set up Sterling to score through Lukasz Fabianski's legs in the 51st minute before Jesus had a well-worked team effort ruled out by VAR for offside. Sterling, played in by David Silva before he crossed for Jesus' tap-in, appeared to have his shoulder ahead of the defender.
Ederson was forced to make a double save from Javier "Chicharito" Hernandez, then Lanzini in West Ham's best phase.
"They had an incredible chance and it could go 1-2 with 15 minutes left. So you have to be strong, calm and positive. You have to control your emotions," said City coach Pep Guardiola.
VAR was needed again when Sterling grabbed his second in the 75th, timing his run for Mahrez's ball over the top before lifting it over Fabianski, and this time, the goal was allowed.
Then Aguero was given a second chance to take his penalty after Fabianski saved his first effort. A VAR check showed Declan Rice was encroaching in the penalty area.
Aguero made it 4-0 in the 86th and Sterling wrapped it up in injury time, becoming the first player since Didier Drogba in 2010-11 to score a hat-trick on the league's opening weekend.
Elsewhere, Brighton beat Watford 3-0 in a dream debut for new manager Graham Potter. In the 64th minute, Potter sent on two forwards — new signing Neal Maupay and Romanian striker Florin Andone — with Brighton leading 1-0. Both scored.
Potter enjoyed considerable success with Swedish side Ostersunds FK before taking over Championship club Swansea last season.
Crystal Palace were held to a 0-0 draw by 10-man Everton, Ashley Barnes scored twice as Burnley launched their campaign with a 3-0 victory against Southampton, and substitute Billy Sharp scored a late equaliser to help promoted Sheffield United draw 1-1 at Bournemouth.