A closely-contested match looked destined for extra time until substitute Miles Storey broke through the Torquay defence and set up as easy chance for Williams from close range.
Swindon had the better chances and should have gone ahead in the 56th minute when Alex Pritchard, on loan from Tottenham, was brought down by Lee Mansell to concede a penalty.
But Pritchard's effort to the left of goalkeeper Martin Rice was pushed away to safety.
Williams also twice hit the Torquay woodwork in the 70th minute and then again in the last before eight minutes of stoppage time caused by an injury to Gulls substitute Elliot Benyon, a former Swindon player, who was carried off on a stretcher.
Torquay's best effort fell to striker Callum Ball in the first half but his shot was saved by the diving figure of goalkeeper Wes Foderingham.