Both sides had chances after the break in an entertaining contest but Mahrez’s free-kick and Sterling’s late strike put the game beyond the home side and allowed City to close to within five points of Liverpool.
City looked irresistible going forward throughout but were shaky at the back, with makeshift defender Fernandinho partnering Nicolas Otamendi in central defence in the absence of the injured John Stones and Aymeric Laporte.
If the visitors felt the pressure it did not show in the opening minutes, with Guardiola’s team quickly into their smooth stride, interrupted only by lengthy treatment for Everton’s Theo Walcott, who was eventually stretchered off.
City, playing in a garish yellow-and-pink kit, should have been ahead early after Mahrez fizzed a ball across the face of the goal only for Ilkay Gundogan to hit the bar with the goal gaping.
But they took a deserved lead midway through the first half when Mahrez found Kevin De Bruyne, who placed a delightful curling cross onto the head of Jesus, an unused substitute during City’s 8-0 demolition of Watford last week.
The home side responded brightly, with Gylfi Sigurdsson going close, and pulled level in the 33rd minute when Seamus Coleman chipped over Ederson from a tight angle and Calvert-Lewin headed in on the goal line.
City had chances to restore their lead before half-time but Jesus blazed over and Gundogan fired straight at Everton goalkeeper Jordan Pickford.
Early in the second half De Bruyne hit the side-netting before Ederson was called into action at the other end, tipping over Yerry Mina’s close-range header as Everton went toe to toe with last year’s domestic treble winners.
Sterling missed a glorious chance to put City back in front on the hour mark, side-footing wide from Mahrez’s incisive pass.
But the visitors eventually got the goal they craved when Mahrez curled a free-kick into the bottom corner past a despairing Pickford with about 20 minutes remaining.
Still Everton were not finished, with Ederson charging off his line to keep out Calvert-Lewin’s goal-bound effort and the ‘keeper was called in to action minutes later to keep out another Mina header.
But Sterling made sure of the win when he smashed an effort against the underside of the bar and goalline technology confirmed it had crossed the line.