Substitute Marco Futacs struck an injury time winner just seconds after Dave Kitson had appeared to handball over the line to draw his side level.
It was harsh on Rovers who had been in control after Habib Beye and Fabien Robert netted in the opening five minutes but a chaotic game turned on the questionable dismissal of Beye on the hour.
Kitson fell theatrically under pressure from the veteran Senegalese to give away a penalty that Greg Halford netted before converting a second spot-kick moments later drew his side level.
The drama continued though as James Coppinger immediately fired Doncaster ahead, which would have kept Rovers up and relegated Pompey, until a barely believable finish that left the home fans hooting their disapproval at the end.
By contrast the few hundred travelling Pompey fans remained singing after the whistle having avoided what would have been the latest sorry chapter in their recent history.
Boss Michael Appleton vowed that his side would not give up until relegation was assured, which had looked likely following a disastrous opening five minutes.
Only three minutes had passed when Beye netted the opener, rising highest to meet a free-kick and loop his header over goalkeeper Jamie Ashdown.
A stunned Pompey were 2-0 down moments later when Robert stabbed home from close range after John Oster's initial effort had been blocked by Ashdown.
The travelling support behind the goal responded with ironic celebrations although their good humour was almost tested again on seven minutes when Coppinger's dipping 25-yard volley smacked against the crossbar.
Portsmouth's response to the early onslaught was underwhelming as a hopeful 20-yard David Norris shot was the best they could muster before Appleton decided on a change of formation after 28 minutes.
He brought on striker Kitson for winger Dickson Etuhu and it almost paid immediate dividends as Halford saw his firm header cleared off the line moments later.
A Beye header then tested Ashdown again at the other end, the goalkeeper this time punching for a corner, before Robert fizzed a pass across goal that no one was in a position to turn in.
Despite Pompey's predicament their few hundred travelling fans remained in full voice and they cheered louder still when news filtered through that Bristol City had taken the lead at Birmingham, to confirm they would go down with anything but a win.
With that threat looming likely Portsmouth finally showed signs of life soon after half-time with Scott Allen firing against the crossbar from range before Luke Varney drew a low save from an acute angle.
The visitors were then given a hotly-contested penalty on 57 minutes when Kitson fell theatrically under pressure from Beye, who was then also given his marching orders for denying a scoring opportunity.
The veteran Senegalese protested the decision but once he left the pitch Halford tucked in the spot-kick.
The home fans clearly felt aggrieved at the decision and their mood was hardly helped when the referee awarded a second penalty against James O'Connor moments later.
Again Halford scored the spot-kick, despite Gary Woods getting a hand on the ball.
Portsmouth may have been lucky to be level but it lasted just four minutes as Coppinger netted a fine solo goal.
After being released down the right he cut inside and fired a low shot that took a deflection as it went through the legs of a defender to ensure Ashdown was wrong-footed.
Doncaster then set about holding onto their advantage, which would have kept their slim survival hopes alive, but with time ticking down they conceded a third dubious goal when Kitson appeared to handball over the line.
It got better for Pompey in injury time when Futacs popped up in the area and slid in a winner in to send Doncaster down after four years in the Championship.