It looked as though Pep Guardiola was going to be left frustrated for the second time in a week following the home draw against Everton before Sterling's last-gasp strike looped in off Andrew Surman to seal a 2-1 victory.
Sterling was shown a second yellow card after celebrating in among the jubilant away fans as Bournemouth were left with nothing to show for a strong showing after Gabriel Jesus had initially equalised a stunning Charlie Daniels strike.
Bournemouth, who went into this game having lost their opening two Premier League fixtures, were largely unfancied here but Eddie Howe's shift to a back three helped them deal with City's wealth of attacking talent for much of the contest.
The hosts did well to keep the pressure on Guardiola's men in the early stages and it led to them taking the lead in spectacular fashion.
Dan Gosling's cross was headed away from the near-post by Vincent Kompany only for Daniels to latch onto the loose ball and arrow a drive past Ederson and in off the crossbar from an acute angle.
While City's talented forward line was struggling to get a foothold in the game, Bournemouth's veteran frontman Jermain Defoe almost doubled the Cherries advantage.
Starting his first Premier League game for the club, the 34-year-old met Surman's cross but Ederson made a smart save to keep out his effort.
The miss proved costly as City levelled moments later, Jesus taking a swift free kick to David Silva, whose slide-rule ball back to the Brazilian was converted with ease by the forward.
Gabriel Jesus passed up a marvellous opportunity from the next attack, firing debutant Benjamin Mendy's low cross wide when free at the back-post.
Silva then blazed over before Asmir Begovic made a decent stop to keep out Danilo as the title favourites started to find their groove.
The visitors continued their domination after the interval but it was Joshua King who came within centimetres of putting Bournemouth back in front, only for the former Manchester United man to see his effort come back off the inside of Ederson's post.
Guardiola turned to Aguero with 25 minutes remaining as the Argentine replaced Bernardo Silva, who had some nice moments on his full debut for the club.
Aguero was straight into the action, seeing calls for a penalty turned down by referee Mike Dean before firing straight at Begovic when well-placed.
It was his compatriot Nicolas Otamendi who should have put City in front but his free header from Kevin De Bruyne's corner hit the frame of the goal.
With time running out, Sergio Aguero could only bend a free kick wide of goal before Howe and Guardiola were involved in an argument on the touchline as the fourth official signalled five minutes of added time.
Those five minutes had all-but elapsed when, after King had been denied at the other end, Sterling collected the ball inside a packed Bournemouth box and saw his effort hit Surman and nestle in the corner of Begovic's goal.
Dean then issued the England winger with his marching orders for his celebrations but there was no time for Bournemouth to take advantage of the dismissal.