York went ahead when the Gillingham defence failed to deal with Patrick McLaughlin's corner and Lee diverted the ball into his own net on 17 minutes.
Gills skipper Adam Barrett nearly levelled things before the break with his header while York's Chris Smith saw his header hit the bar on the hour.
But McDonald finally got the break through, glancing in Miles Weston's looping cross to rescue a point but he failed to dampen Mills' enthusiasm.
"My players were fantastic," he said. "It's a very difficult place to come and I've got nothing but praise for them from start to finish.
"I thought we deserved the win, and I really believed we'd hold out for three points.
"We know when you come to Gillingham you'll have to defend long throws and balls going in early and we dealt with that well.
"When we got the ball we opened them up a few times and passed it just how I wanted. I've told the players how pleased I am, I think they were all fantastic.
"We created some great chances, with Smith hitting the post when we were 1-0 up an Ingham pulled off a couple of great saves.
"We've come here and showed that we're a tough side to beat and showed we're quite capable of winning games, and certainly not losing them."