The Robins took a surprise lead after 38 minutes when Simon Cox scored his 19th goal of the season. He was put through by Billy Paynter and out-stripped City’s rearguard to unleash a shot which was blocked by David Martin before he followed up to sweep home the loose ball.
Earlier Peter Brezovan came to Swindon’s rescue when he bravely blocked King’s close-range drive.
Youth Academy graduate Carl Pentney came off the bench on the hour mark to replace the injured Martin and rescued City twice, first when he blocked Cox’s goal-bound drive and then instinctively stuck out a leg to keep out a Hal Robson-Kanu shot.
Michael Morrison crashed a header against the underside of the crossbar before King nodded wide of a gaping goal.
But King showed great composure after 86 minutes when he stepped inside a defender to steer a shot beyond the keeper from 16 yards.