League One: Swindon 1 Preston 0
Having replaced Jonathan Obika with 19 minutes to play, Williams rose to head home his eighth goal of the season with six minutes left at the County Ground.
The victory moves Swindon into third place in the league table, just two points behind Preston, who fell to a second successive defeat.
Preston began the clash the livelier with Joe Garner and Paul Gallagher causing the Swindon defence problems, but the duo found goalkeeper Wes Foderingham in good form.
All Swindon's best chances fell to Obika and he could have had two goals had his accuracy been better.
Town continued to assert pressure on the Preston goal after the break, only for Jamie Jones to produce good saves to deny Michael Smith and Harry Toffolo.
Both sides had further chances to open the scoring, but it was Swindon who finally got the breakthrough with time running out.
Ben Gladwin's cross took a deflection on its way into the penalty area and Williams managed to escape his marker to net a powerful header.