The former Manchester United captain cupped his ears to taunt the home supporters as he became only the second player, after Alan Shearer, to reach a double century in the Premier League.
And when Kyle Walker was sent off before the interval — a fate that would also befall Everton’s Morgan Schneiderlin for a second yellow two minutes from time — the odds were stacking against the hosts.
But on 82 minutes, Danilo’s right-wing cross was headed out by youngster Mason Holgate straight to Sterling who volleyed in clinically from 15 yards.
Everton had pounced after 35 minutes and, inevitably, it was Rooney whose 11 goals against City during his United career stands as the record for any striker in Manchester derbies.
It came from a City error, Leroy Sane gifting the ball to Holgate who launched a counter-attack down the right.
With City back-pedalling furiously, Dominic Calvert-Lewin had the composure to pick out the fast-arriving Rooney on the edge of the six-yard area and the Everton forward finished through the legs of Ederson.
“It was nice,” Rooney said of his landmark goal. “To do it today in such an important game for us, with tough games coming up, it was a sweet moment and I am sure the red half of Manchester will have enjoyed it as well.”
Worse would follow before the interval for City as Walker, booked on 41 minutes for a foul on Leighton Baines, picked up a second yellow card just two minutes later after colliding with Calvert-Lewin.
The second booking, certainly, looked downright wrong — something confirmed by television replays — and Guardiola protested furiously, and understandably, with the fourth official about the blatant error.
It had all been going according to plan — relatively speaking — until the opening goal.
City staged a pre-match firework display so over the top that the game kicked off shrouded in mist but, once the smoke had cleared, the visit of Everton was always going to provide Guardiola with an interesting early-season gauge of his team’s progress.
Those pyrotechnics were part of a new fans’ package rolled out by City — “The Tunnel Club” in which supporters can pay £15,000 (€16,400) a season to walk onto the pitch before kick off, wine and dine, and have access to the tunnel area at half and full-time via a two-way mirror.
It may not be football like your grandfather knew it, but this is the world that the modern Premier League inhabits and, as far as gimmicks and the generation of money are concerned, City are top of the table by a considerable margin.
Once the firework smoke had lifted, it was a question of whether Guardiola is building a team capable of topping the actual league table and the visit of an Everton side which has already played four league and European games — winning all four without conceding a goal — would clearly pose a test.
But City appeared to be coping well and by far the more likely team to open the scoring.
Moments before Rooney’s opener, in fact, Sergio Aguero’s delightful lob forward found David Silva whose thunderous first-time strike appeared likely to shatter the post as it struck it and rebounded to safety.
That was the latest in a series of chances which started after five minutes when Jordan Pickford had to be sharp to keep out Kevin De Bruyne’s deflected free-kick at the foot of his post.
Defender Nicolas Otamendi also forced the Everton goalkeeper into a diving save with Aguero clipping the rebound goalwards for Phil Jagielka to clear. The Everton skipper also got in a vital block on Aguero as De Bruyne played him through and the unusually quiet Gabriel Jesus ended the half with a shot straight at Pickford.
Guardiola had certainly seen enough of Jesus by that stage, hauling him off at the interval in favour of England forward Sterling whose place looks under particular pressure among City’s embarrassment of attacking riches.
After the break, there were early shots from Aguero and De Bruyne that offered no threat and a 25-yard free-kick from the latter which he hammered straight into the defending wall, Silva doing the same with a follow-up from the rebound.
But as the game entered its final 20 minutes, there were still precious real chances until Sterling’s late intervention.
Ederson 6; Kompany 7, Stones 6 (Danilo 64, 7), Otamendi 7; Fernandinho 6; Walker 6, De Bruyne 7, D Silva 6, Sane 5 (B Silva 69, 7); Aguero 6, Jesus 5 (Sterling 45, 8).
Bravo, Mangala, Toure, Foden.
Pickford 7; Keane 8, Williams 7 (Klaassen 60, 7), Jagielka 9; Holgate 6, Schneiderlin 6, Gueye 7, Baines 7; Davies 7 (Sigurdsson 60, 6), Rooney 8 (Besic 89); Calvert-Lewin 7.
Stekelenburg, Mirallas, Martina, Lookman.
B Madley 4