Michael Jacobs gave the Cobblers a 22nd-minute lead from the penalty spot after he had been tripped by Jonathan Smith as he waltzed into the box.
Saido Berahino almost doubled Northampton’s lead after the restart when his header was superbly saved by Wes Foderingham. But Swindon stepped up a gear with Oliver Risser poking a shot wide at the near post and substitute Simon Ferry glancing a header wide.
Substitute Alan Connell finally equalised in the 66th minute, getting on the end of Risser’s pinpoint pass to turn inside Ashley Corker and find the bottom corner of the net from 12 yards. Risser was then red carded for a challenge on John Johnson in the 78th minute.
Connell failed to connect with Murray’s inviting low cross in the 88th minute and Berahino blazed over two minutes later. But McCormack hit the winner from close range three minutes into stoppage-time after being picked out by Raffaele De Vita.
That prompted wild scenes on the Swindon bench and manager Paolo Di Canio was sent to the stands for his over-zealous celebrations.