The home side took the lead when Leroy Sane crossed for David Silva to finish on 29 minutes.
Seven minutes later the lead was doubled, Gabriel Jesus converting a penalty after Sane had been fouled by Yohan Benalouane.
Leicester pulled a goal back before the break in spectacular fashion, Shinji Okazaki volleying in Marc Albrighton’s cross.
Mahrez had a chance to equalise with 13 minutes left after being fouled by Gael Clichy but a slip meant he kicked his penalty against his own foot before it went in, forcing referee Robert Madley to disallow it for two touches.
Under Leicester pressure, Man City held on to go two points clear of Liverpool in third. Leicester remain ninth.