Gray, famous for his villainous role in Coronation Street as well as parts in Casualty, Taggart and more recently the critically acclaimed The Loch, shared the news to followers on Twitter.
He said he was given the diagnosis after seeing a doctor about swollen glands in his neck.
The actor, 51, from Glasgow, thanked Beatson Cancer Charity as he posted a video of himself ringing a hospital bell to signal the end of his treatment.
Gray wrote: "About three months ago a trip to the doctors with swollen glands led to stage four tonsil cancer. Today marks the end of my treatment and I couldn't be more thankful to everyone who has supported me along the way."
His message has been shared more than two thousand times on social media.
Radio DJ and panto star Grant Stott wrote: "Mate, I had no idea. So sorry you’ve had a hellish time but delighted to see you ring that feckin bell!!! Hugs and love for your recovery."
Actor Colin McCredie added: "That is so bloody awful. So pleased to see you “ring the bell”. Sending my very best."
Speaking later, he said: "When I received the diagnosis of tonsil cancer I was of course devastated - it's cancer. My reason for waiting to ring the bell before I mentioned it publicly is because I wasn't sure how strong I would be in coping with the treatment, indeed could I cope with the treatment?
"Even though I was told what to expect after the chemotherapy and what to expect after 30 rounds of radiotherapy I wasn't sure how my body would react, and now six weeks later I have been able to cope with it and I was able to ring the bell.
"This is only the treatment finished. I now have a long way to go with my recovery. I have been advised it will get worse before it gets better, and I have no reason to doubt this. The accuracy of the medical advice I have received with regards to the treatment and how it's progressed has been spot-on so far. As long as I take it a day at a time as I have up until this point I am looking forward to coming through the other side.
"A final word to all those who have helped me thus far - every single one of those lifts to and from the Beatson Cancer Centre - you know who you are. Thank you so much."