The Croatian champions were buoyant after a 4-0 thrashing of Atalanta in their Group C opener and the visitors held firm until midway through the second half at the Etihad Stadium on Tuesday.
Sterling's close-range finish and pass for Foden to score in added time ensured Pep Guardiola's side, who toiled without their injured playmaker Kevin De Bruyne, top the group with a maximum six points from their two games.
City took time to find their rhythm but Dominik Livakovic had to race off his line to block from Sergio Aguero in the 13th minute, Bernardo Silva then wasting a chance on the rebound.
Joao Cancelo was arguably fortunate only to be booked for a high boot on Dani Olmo, then Ilkay Gundogan rattled the crossbar and David Silva missed from eight yards out.
City saw penalty appeals after an apparent handball rejected and Aguero lashed home in the 25th minute but the whistle had already gone after Bernardo Silva inadvertently handled.
Guardiola sent on Sterling early in the second half and the former Liverpool forward eventually forced the breakthrough in the 66th minute.
Rodri's pass broke Dinamo's defensive line and when Riyad Mahrez slotted a low cross into the six-yard box, Sterling was there to steer in his 11th goal of the season for club and country.
Guardiola was booked for displaying his frustration at Sterling not being awarded a penalty shortly after the deadlock was broken and City finally got their second in the fifth minute of added time, Foden confidently netting his first of the season at the end of a swift breakaway.
What does it mean? City miss De Bruyne
With nine assists from nine appearances this season, it was always likely City would be less than their fluent best in the absence of De Bruyne, who missed out with a minor groin injury.
Although captain David Silva had an excellent game, De Bruyne is the player who takes City to a new level and without him Dinamo were able to funnel the Premier League champions into wide areas, where they struggled to create chances.
Sterling hot streak continues
Leaving Sterling on the bench when De Bruyne was already sidelined was a slight risk from Guardiola and the manager had to turn to the England international to break the deadlock. He has now scored in three consecutive appearances, which have each come in different competitions, while he unselfishly set up Foden at the death.
Misfiring Mendy leaves City imbalanced
David Silva's tendency to drift left meant there were plenty of chances for fit again full-back Benjamin Mendy to rampage down the wing, but his delivery from key areas was lacking.
He delivered 13 crosses, easily the most of any player on the pitch, but only two were good and when Mahrez popped up in a similar position he picked out Sterling for the opener.
City welcome Wolves to Manchester on Sunday and their matchweek three fixture is at home to Atalanta. Dinamo host Slaven Koprivnica in the Croatian league at the weekend with their next Group C game away to Shakhtar Donetsk in three weeks' time.