The winger who has had to be content with cameo roles in the Premier League since the turn of the year continued with Cup duty, starting alongside Gabriel Jesus and Leroy Sane in
City drew blank in the opening 45 minutes against the stubborn League One side, but Sane broke the deadlock six minutes after the restart.
Youngster Phil Foden doubled their lead with 15 minutes left on the clock, but Rodney Padraig's 88th-minute effort set for a tense finale at Rodney Parade.
Foden responded almost immediately before Mahrez scored in the stoppage time to send Pep Guardiola's men past their League One hosts.
The 27-year-old has now hit double figures in his maiden season with the Etihad outfit, with Saturday's strike taking him to 10 goals in 34 outings across all competitions.