Pep Guardiola's side seemed to do everything but score in a one-sided first half at the Etihad Stadium but it took the second-half introduction of Sterling to break the deadlock.
The England forward struck in the 66th minute to put City on course for top spot in Group C before Phil Foden added a second in injury time.
After 19 attempts on goal few could quibble with the result but City's lack of a cutting edge, although key man Kevin De Bruyne was missing with a groin injury, might be of concern to Guardiola.
The City boss himself did not have a quiet night as he was booked in the second half for protesting about a refereeing decision. That came after City had also been frustrated by the VAR system before the break, denied a penalty for handball.
City have had little luck with VAR since it was introduced and another penalty appeal was turned down late on.
Most of the noise in the ground came from Dinamo's small but lively contingent of around 1,300 fans. They even took their tops off en masse at one point, so much were they enjoying the occasion, but all the good play came from City.
Even without De Bruyne, City looked far too strong and cut through them at will in the first half.
They had a triple chance to take the lead early when Sergio Aguero went through on goal only to be denied by Dominik Livakovic as he tried to round the keeper.
Ilkay Gundogan tried his luck on the rebound but his effort was blocked and Bernardo Silva's follow-up attempt flew over the bar.
Bernardo Silva went close again when he volleyed wide and Aguero also missed the target after a nice turn.
Gundogan smashed a shot against the bar and David Silva remarkably poked another attempt wide from close range.
City might also have felt they could have had a penalty after the ball hit Kevin Theophile-Catherine's hand on its way through the box but neither referee, nor VAR, saw anything untoward. Aguero then had a strike disallowed for a handball by Bernardo Silva.
City began to look a bit more laboured after the break and Guardiola gave it only 11 minutes before introducing Sterling.
It was a change that paid immediate dividends as Sterling enlivened the City attack from his first touch.
After a couple of good runs he then played in David Silva, whose cutback across goal was anxiously cleared by Dinamo.
Sterling then made the breakthrough himself, turning in from close range – albeit via deflection – from a Riyad Mahrez cross following a flowing team move.
Sterling continued to trouble the Dinamo defence and was tripped just outside the area, stumbling inside it. Dutch referee Serdar Gozubuyuk gave nothing, much to the frustration of Guardiola on the touchline, and the City boss was shown the yellow card for his protestations.
City had another penalty appeal late on when Gundogan was bundled over but, after a lengthy VAR stoppage, play continued.
In the end it did not matter and Foden put the seal on the victory in added time as he raced through to score following another break by Sterling.