After Liverpool's 1-0 win at Sheffield United, the pressure was on City not to allow Juergen Klopp's side to open up an eight-point lead so early in the campaign.
While the scoreline might suggest a comfortable victory for City, in truth Pep Guardiola's team were given a real test by an Everton team that produced eight shots on target and played with aggression and intensity.
Indeed City had Brazilian keeper Ederson to thank for vital saves and not until Mahrez and Sterling struck in the final 20 minutes could the champions feel secure of the points.
Everton suffered an early blow when they lost winger Theo Walcott in the opening minutes after he was struck in the face by a Sterling cross and had to be taken to hospital for checks.
After Ilkay Gundogan had hit the bar from close range for City, the visitors grabbed a 24th-minute lead when Brazilian Jesus stooped at the back post to head in a perfectly-lofted Kevin De Bruyne cross.
A determined Everton got back on level terms, though, nine minutes later, when after poor clearance from Fernandinho, Seamus Coleman lofted the ball goalwards and Dominic Calvert-Lewin dived to make sure with a header on the line.
Spanish holding midfielder Rodrigo was heavily involved for City, composed and classy on the ball, but with Bernardo Silva, David Silva and Sergio Aguero on the bench, City looked a little short of their usual quality in possession.
Ederson produced a magnificent save to keep out a header from Yerry Mina after the Colombian defender had lost his marker and powered the ball down into the ground.
Sterling should have scored after Mahrez put him clear with a sublime pass but the England forward, who did not enjoy one of his better days, shot wide with only Jordan Pickford to beat.
Mahrez, a frequent threat down Everton's left, took it upon himself to make the difference, with a low free kick into the far corner after Mina had recklessly brought down De Bruyne on the edge of the box.
Ederson had to come to the rescue for City again, getting down well to keep out another Mina header but Sterling made sure of the three points, blasting home off the underside of the bar after a low cross from substitute Aguero was deflected out off Pickford's foot.
Liverpool lead on 21 points with City on 16. Everton are in 15th place on seven points.