The former Northern Ireland under-21 international initially arrived on a month's loan but has now secured a deal until the end of the season.
Gray told the club`s official website: "I am delighted. As soon as I came through the door on loan, I was working towards it becoming permanent. I put a bit of pressure on myself but, now I know I am here until the end of the season, I think I can kick on."
Explaining his decision to sign a permanent contract, Gray added: "It is the size of the club and the fan-base. I have played in the league for numerous clubs but the set-up here is probably the best. Everything is in the right direction for the club to go one way and that's why I am staying on board."
Commenting on the deal, sporting director Dave Penney said: "We like James and he gives us options. It's great to have four out-and-out strikers now so, when the front two tire, you can put fresh legs on and see a game out.
"A month ago we would have lost (against Curzon Ashton) at the weekend - because we didn't have the bodies or the fresh legs to put on. We feel James will be of great benefit to the squad between now and the end of the season.
"We feel, in certain areas, people have been 'guaranteed' a place but now we have added competition for places," Penney added. "Hopefully, this will make us stronger as a squad".