The Foxes’ boss was shown the door last week, seeing Michael Appleton take over on a caretaker basis.
But Leicester bounced back strongly from the news, with Mahrez setting up both goals in their victory at Liberty Stadium.
Asked if the win was for Shakespeare, Mahrez said: “Of course. He was our manager and everyone loved him at the club.
“It was a surprise for us. But we have to try to honour the club because the most important thing is the club. We played good today and we deserved to win.
“It was a difficult week for us as everyone knows.
“It was good that we won today, it was an important game for us and for the club. I think we put everything on the side and we played our game and we got the three points.”