Midfielder Thompson converted a Nathan Byrne cross in injury-time to put the Robins just one point off the top-six.
Miles Storey, match winner at Tranmere in midweek, had put the home side in the lead after 18 minutes.
He fastened on to Ben Gladwin's defence-splitting pass and used his pace to burst through and drill a fierce shot into the top right-hand corner of the net.
Nigel Clough's men had won 10 of their last 12 matches going into this game but looked strangely lethargic and struggled to get any fluency into their play.
But Wes Foderingham produced two stunning fingertip saves from Conor Coady and John Brayford before Michael Doyle equalised after 59 minutes, tapping in a Kieron Freeman cross.
Doyle had a chance after 82 minutes to seal the three points but shot just wide of the post, and it was Swindon who had the last laugh when Thompson popped up at the death.