Cruising at 2-0 up after Mahrez's second half strike had added to Leroy Sane's opener, City suddenly had to dig deep in the last five minutes after the hosts pulled a late goal back.
Despite some late scares, Pep Guardiola's leaders held on to claim the win and move five points clear at the top of the table.
“You are not going to win every game 4-0 or 5-0. Going through these types of games makes you stronger," said the Algerian.
“We played very well up until the second goal.
“After that we created more chances and tried to kill the game but in football when you are 2-0 up and the oppositions score, the crowd get behind them and it's difficult.
“We are very happy to win and get the three points.
“Now we need to focus every three days. We need to be ready and at our top. Anyone in the top four can still win the league.
“Nothing is done and we need to keep working very hard for each other and the team and trying to win every game."