The 20-year-old scored two goals in 16 appearances last term having joined from Kettering at the beginning of the 2012/13 season and was delighted when new manager James Beattie asked him to stay.
Gray said: "He spent hours with me on the training ground last season trying to improve me so I was delighted to hear he wanted to sign me for next season."
He added: "I was pleased with my first season. Next year I won't be an unknown player in the Football League because I'll have that little bit of experience behind me. There will probably be a bit more pressure on me but I can't wait for the season to start."
Gray has also won international recognition at Under-21 level with Northern Ireland and he joins George Miller, Ian Dunbavin, Dean Winnard and Laurence Wilson in agreeing contract extensions with the club.