The Citizens started the game unimpressively after they fell to two early goals from Matt Grimes and Bersant Celina.
Bernardo Silva halved the deficit before Kristoffer Nordfeldt own goal and Sergio Aguero strike sealed the win.
The Algeria international who featured for 57 minutes in the encounter has taken to the social media to applaud his side.
“Tough game in Wales but we got to the next round,” Mahrez posted on Instagram.
Manchester City will keep a date with Brighton and Hove Albion for a place in the final billed for April 5.