Liverpool's 1-0 victory at Sheffield United earlier in the day extended its 100 per cent start to the season and moved the Reds eight points clear of City at the top of the table.
After Dominic Calvert-Lewin's fourth goal in three matches drew Marco Silva's men level after Gabriel Jesus's opener, it looked like City would follow its previous last away game — a 3-2 loss at Norwich City — with another disappointing result on the road.
But Mahrez, who has scored in three consecutive City starts, beat Jordan Pickford with a low curling free-kick and Sterling added gloss to bring the champion back to five points adrift of Jurgen Klopp's leading side.
Mahrez forced a first-minute save from Pickford before a long delay as medics tended to a Theo Walcott head injury, the winger taken to hospital for a precautionary assessment after being replaced by Alex Iwobi.
Algeria star Mahrez made a lively start and Ilkay Gundogan should have converted his excellent cross, the midfielder somehow crashing his shot against the crossbar from virtually on the line.
City's dominance told in the 24th minute, De Bruyne delivering a first-time cross that was impossible to defend, with Jesus — preferred to Sergio Aguero up front — stooping to nod home.
Everton levelled within 10 minutes, Fernandinho's error contributing as Seamus Coleman chipped Ederson, with Calvert-Lewin stealing the goal on the line.
De Bruyne hit a shot into the side-netting after the restart while Ederson made a fine save to keep out Yerry Mina's downward header.
Mahrez's rich vein of form crucially continued with a set-piece that beat an unsighted Pickford, and two missed chances from Calvert-Lewin proved costly as Sterling marked his 200th City appearance by scoring off the underside of the crossbar with six minutes to go.