Late goals from Jason Price and Brian Stock gave Doncaster a boost in their fight for promotion.
Price gave Rovers the lead when he rose highest to head home Stock's right-wing corner and stun Gillingham.
Stock then pounced on Danny Spiller's error to lash home to hand Rovers an eighth league win in nine games.
A flying save by Benjamin Smith from Michael Flynn's free-kick stopped the Gills skipper from breaking the deadlock in the second half.
Gillingham: Brill, Easton, Cox, Chorley, Sancho, Crofts, Flynn, Bentley (Spiller 84), Jarvis, Mulligan, Savage (Ndumbu-Nsungu 85).
Subs Not Used: Jackman, Jupp, McDonald.
Booked: Savage.
Doncaster: Smith, O'Connor, Lockwood, Gilbert, Lee, Price, Stock, Paul Green, Heffernan (Guy 90), Forte (Stephen Roberts 86), Coppinger (Wilson 90).
Subs Not Used: Dyer, Thornton.
Goals: Price 81, Stock 88.
Att: 6,202
Ref: T Kettle (Berkshire).