Doncaster had led 24-14 at half-time, thanks to two tries from Latu Makaafi and one from Tyson Lewis, before big-spending Bristol drew level at 24-24.
But Flockhart sliced through the home defence in the 73rd minute to seal a bonus-point victory for Clive Griffiths’s brave Knights, before his own penalty and Vili Veikoso’s late try compounded the hosts’ woe.
Doncaster put themselves under pressure from the kick-off, knocking on with their first touch of the game, from which Bristol ran the ball wide, with Gavin Henson playing in Jack Tovey to score.
The visitors hit back almost instantly, though, forcing a penalty, from which they kicked to touch and leading try-scorer Makaafi was driven over, with Flockhart converting to make it 7-7.
Doncaster were next to score, too, Will Hurrell running a piercing line off a line-out, before shipping the ball to the supporting Lewis to score, with Flockhart making it 14-7.
That became 21-7 when the Knights had more joy at the close-range maul, Makaafi grabbing his second try of the game as Bristol were driven back over their line.
The hosts rallied, with Nick Koster tunnelling over from a line-out drive, but Doncaster ended the half on top, Flockhart landing a 40-metre penalty.
Bristol made the brighter start to the second half, though, scrum-half Will Cliff racing through.
That made it 24-21 to Doncaster – which was still the case when Makaafi returned from 10 minutes in the sin-bin for a high tackle on Jack Wallace.
But Bristol drew level when returning World Cup star Matthew Morgan knocked over a 35-metre penalty after the hosts came back into the game.
There was time for further drama, though, as Flockhart finished off a sweeping Doncaster move to give his side a 29-24 advantage, before making the points safe with a 20-metre penalty. Morgan landed a penalty, before Veikoso crossed for the Knights’ fifth try to seal a glorious win.