Following the news, Gary took to Twitter to thank his fans for their support - and even hinted that he could one day return to Albert Square.
"Thank you for your messages. loved my time @Ee interesting character with lots of scope. see u late rather than goodbye ;-) ps more 2 come x."
Earlier this month, the 32-year-old urged critics to "get with the times" after complaints about his character's onscreen kiss with newcomer Johnny Carter (Sam Strike).
"Reaction was, on the most part, positive," Gary said. "There were a few on Twitter living in the dark ages but on the whole, people were ok.
"I got one message on the internet from a guy saying, 'Thanks for that storyline because it gave me the courage to come out and tell my parents.' If you can do that, you as an actor and the show has done its job."
Before joining the cast of EastEnders, Gary was best known for his roles as DC Will Fletcher in The Bill, Kyle Pascoe in Footballer's Wives and Luke Morgan in Hollyoaks.
An EastEnders spokesperson said of his departure, "We can confirm that Gary is leaving EastEnders later this year and we wish him all the best for the future."