But it needed a goal five minutes from time from striker Paul Connor to maintain their League One status.
An even first period saw the Robins start well and take the lead after 24 minutes when Steven Gillespie held off his marker and squeezed the ball between keeper Neil Sullivan and his far post.
But the goal lifted the visitors and they almost drew level before the break, with Sam Hird being denied by a good save from Shane Higgs, while Gareth Taylor had an effort cleared off the line.
Doncaster kept up the pressure in the second half, but Higgs denied them with a string of fine saves.
Doncaster finally levelled after 76 minutes through a Paul Green shot, but Cheltenham put any fears of the drop behind them when Connor scrambled home the winner nine minutes later.