Ali, 34, made his Test debut back in 2014 and went on to represent England in 64 Test matches.
He took 195 Test wickets including 5 five-wicket hauls and scored five Test match centuries during his career.
Discussing his decision, Ali said: “I’m 34 now and I want to play for as long as I can and I just want to enjoy my cricket.
“Test cricket is amazing, when you’re having a good day it’s better than any other format by far, it’s more rewarding and you feel like you’ve really earnt it.
“I will miss just walking out there with the lads, playing against best in the world with that feeling of nerves but also from a bowling point of view, knowing with my best ball I could get anyone out.”
“I’ve enjoyed Test Cricket but that intensity can be too much sometimes and I feel like I’ve done enough of it and I’m happy and content with how I’ve done.”
Ali hopes that his Test career will inspire and open the door for other British Muslims to play for England.
Ali added: “It always takes somebody to inspire you or takes somebody to think if he can do it I can and I hope there are a few people out there who are thinking that.
“I know he wasn’t English but someone like Hashim Amla, when I first saw him, I thought if he can do it I can do it, it does take that little spark.
“I’d love one day in 8-10 years’ time to say Moeen made it easier for me. There have been guys before me who made it easier, so you hope to open the door for someone else.”
Ali thanked his coaches, captains and all of his family for their support during his Test career.
Ali said: “I have to thank Peter Moores and Chris Silverwood for being my coaches and Peter for giving me my debut. Cookie and Rooty as the captains who I’ve enjoyed playing under and I hope they are happy with how I played.
“My parents are my number one, I feel without their support there is no way I would have made it, every game I played was for them and I know they are really proud of me.
“My brothers and my sister, on my bad days they’ve been the first to pick me up and my wife and kids, my wife’s sacrifices and the patience she has, I am really grateful for that.
“They have all been amazing on my journey, everything I did I did for them.”