On loan striker Jonathan Forte was both hero and villain as Doncaster recorded their fourth win in a row to climb the table.
Forte displayed dazzling pace before firing Rovers in front after 36 minutes but was sent off four minutes from time following a second bookable offence.
Swindon also finished with 10 men with centre-back Jerel Ifil dismissed for his second bookable offence in the last minute to relieve the pressure on Rovers who were under the cosh at the time.
Doncaster started as if they would overwhelm their opponents who had caretaker boss Iffy Onuora in charge for the first time after sacking manager Andy King during the week.
But the home side's attacking play lacked a cutting edge and they made heavy weather of it when they lost their grip in the second half.
Swindon looked like a team lacking in confidence as they were outclassed in the first half but produced plenty of spirit and determination when the chips were down to give Onuora some hope of a quick change in fortunes.
Town were first to threaten and should have taken the lead in the second minute but Tony Thorpe dwelt for what seemed like ages on a gilt-edged chance and had the ball whipped away from him before he could manage a shot.
For the rest of the half it was virtually one-way traffic with Tom Heaton doing well to save from Uros Predic in the seventh minute and Forte fired inches over the top one minute later.
Leo Fortune-West headed a good chance wide and Forte was just unable to round off another sparkling move before Rovers went ahead in the 36th minute.
Forte left Ifil for dead despite giving him a couple of yards start in a sprint for a long ball before firing home from a tight angle.
Home keeper Jan Budtz produced a brilliant save to prevent Rory Fallon from levelling just before the interval and was out of luck again when he had a header cleared off the line in the 73rd minute.
Rovers lost their way in the second half with Fortune-West missing a sitter and looked in trouble when Forte was sent off for time wasting in the 86th minute after earlier being booked for celebrating his goal.
But Ifil's dismissal for a foul in the last minute took the sting out of the game and Rovers held out for a hard-fought victory.