Football League Wrap: County win under Derry
County remain bottom of the League One table despite the club's first victory since the end of October, but Derry's men are now just three points from safety.
Celtic loanee Callum McGregor put them in front after 40 minutes and although Gillingham equalised through Bradley Dack just after half-time, parity lasted just six minutes as McGregor got a second.
And Jack Grealish sealed the win three minutes from time as County recorded a rare triumph, only the side's fourth in the league this season and first since Derry took charge at the start of November.
In Saturday's other Football League clash, Cheltenham Town extended their unbeaten league run to eight matches with a 1-0 win at Morecambe in League Two.
Troy Brown scored the only goal of the game 10 minutes from time, tapping in from close range to lift Cheltenham to 13th.
There were just two Football League matches staged on Saturday due to the second round of the FA Cup.