The one-time Northern Ireland call-up, 23, made nearly 80 appearances for Stanley and scored on 15 occasions, including a run of five in eight games at the beginning of last season.
However, when manager John Coleman replaced James Beattie at the helm in September, Gray found himself surplus to requirements and last featured for Accrington in January.
A loan move to Southport then fell through and he eventually ended the season at Northampton.
“He’s a smashing kid and a great character, and to be honest I’ll miss him around the place,” Coleman said.
“But I’ve been in football long enough, and a goalscorer long enough to know the frustration you get by not starting every week means you can’t score goals. I empathise a lot with him.
“I could have made him sit around and try to demand a huge fee for him, but I don’t think that would have been fair on the player to be honest. He’s done nothing wrong, he’s served the club really well and I wish him all the best wherever he moves to.”
Gray added: “I can’t thank Accrington Stanley enough for giving me the opportunity to play in the Football League.
“I’ve had the best times of my career so far at the club and the club will always be in my heart.
“I’ll miss the backroom staff and people around the club immensely and would like to thank them for how much they have looked after me over the last three years.”