Doncaster almost threw away a two-goal lead before top scorer Paul Barnes hit a splendid late strike to make the game safe.
Rovers dominated for three quarters of the match against a sorry looking Margate side but the visitors hit back from 2-0 down with their first shot on target in the 75th minute.
Doncaster had to endure some anxious moments before regaining control to stay on course for a promotion play-off place.
Rovers were on top from the start with new signing John Doolan impressive on his home debut in midfield.
Paul Green missed a great chance when he hit a half-volley just over the top in the 12th minute before Rovers snatched the lead three minutes later.
Barnes and Green combined to make the opening for Jason Blunt who fired home a low shot from the edge of the box.
Visiting keeper Phil Smith did well to save at full stretch from Robert Gill five minutes later but there was no stopping Doncaster at this stage.
Barnes made it 2-0 in the 27th minute when he turned to hit a spectacular goal from 25 yards with Smith caught napping when the ball skidded off the surface into the bottom corner.
Barnes and Green both went close before the interval and the only surprise was that Doncaster were not further in front when the half-time whistle came.
The one-way pattern continued after the interval with Smith doing well to save from Barnes again in the 57th minute.
But the introduction of substitute Phil Collins seemed to galvanise Margate and he fired just over the bar in the 70th minute.
Margate had seldom threatened until then but they pulled one back in the 75th minute when Collins crossed from the left and Jean-Michel Sigere forced the ball home from close range.
Sigere missed a chance to level the score four minutes later when he fired straight at the keeper from close range.
But Rovers had the last word when Barnes raced onto a superb defence-splitting pass from Doolan to notch the third in stunning style.