The Minstermen became the second National League club to make a change this season.
Gray goes after a slow start, which saw the North club draw 1-1 at home to Curzon Ashton on Saturday.
Youth team manager Sam Collins will step in and assume caretaker responsibility.
Sporting director Dave Penny has shed light on the decision to part with Gray, who had been in charge for under a year.
“It came down to a culmination of things and results were a big factor,” Penny has said today.
“You obviously listen to the boos at half-time and at the end of home games and that has an effect because, as a board member, you can’t ignore it and they have been vocal at other grounds as well.
“We gave Martin a chance to bring his own players in during the summer to see if there was an improvement, but we don’t think there has been.
“We sat down as a board and talked about the situation on Saturday after the game, thought about it more that night and, then, felt we made the best decision for York City in the morning.
"We’re eight points off the top and we’re not happy about.”