A 2-1 home defeat against Lyon in the Champions League on Wednesday left critics questioning whether City were suffering a dip in form.
But Pep Guardiola’s side gave an emphatic reply with their biggest win and most dominant display of the season in south Wales.
Mahrez scored twice, his first goals for the club since his pre-season move from Leicester, and Sergio Aguero celebrated his 300th City appearance with the opener in the week he signed a new contract.
There were also goals for Bernardo Silva and the impressive Ilkay Gundogan as City got back on track in style.
Cardiff suffered their biggest defeat under manager Neil Warnock and are still looking for their first win since last season’s promotion after slipping into the relegation zone.
City actually began hesitantly, as if the shock of the Lyon defeat had not been exorcised.
But they were soon opening up Cardiff’s defence at will with some slick passing on the greasy surface.
Aguero, Leroy Sane and Nicolas Otamendi had all been recalled by Guardiola, with memories still raw for Sane of the injury he suffered at the same venue back in January in the FA Cup.
The villain of that day, Joe Bennett, was relegated to the bench by Warnock, who brought in Greg Cunningham and Lee Peltier into a re-shaped defence.
Mane had his measure of revenge, though, when he played his part in giving City a dominant position by half-time.
Aguero had been relatively quiet, content to pull Cardiff’s worried defenders out of position, but he struck with devastating precision in the 32nd minute.
Gundogan and Silva prised open Cardiff’s defence on the right and when Silva struck a low cross, Aguero gained half a yard on his marker before smacking a first-time shot past Neil Etheridge.
Within three minutes, City had scored again.
This time it was Sane who hit a dipping delivery, which looked unpromising for Silva until the Portuguese midfielder somehow back-headed the ball with enough precision to send it looping beyond Etheridge and into the far corner.
– Slick City –
A third goal for the champions looked far more likely than any comeback and it duly arrived just before the interval.
Gundogan played a neat pass into Raheem Sterling, took the return, and then curled a superb shot with minimum effort into the top right-hand corner.
Warnock looked as if he wanted more passion from his players and he got it when Joe Ralls scythed down Gundogan to earn a yellow card that replays suggested should really have been red.
City were toying with the opposition and Guardiola took off Aguero and sent on Mahrez.
Within six minutes the former Leicester man scored his first.
Sterling began the move down the left, Gundogan got beyond the home defence and his low cross was swept in at the back by a joyful Mahrez.
The Algerian then added a second two minutes from time to rub salt into Welsh wounds.
Cardiff defender Bruno Ecuele Manga seemed to have broken down a City attack, but then cleared the ball straight to Mahrez, who skipped clear of a challenge and fired past Etheridge.