Williams, who has now scored three times in four games, pounced on a loose ball in midfield in the 66th minute and curled in a 20-yard right-footer after jinking past three Hartlepool defenders.
Huddersfield, who were trailing to Garry Liddle's first-half header, had drawn level after 56 minutes through an own-goal by Hartlepool's Peter Hartley.
Town's Anthony Pilkington thrashed a 30-yard free-kick off the post and the ball rebounded into the net off Hartley under pressure from Nat Clarke and Gary Roberts. Hartlepool took the lead after 18 minutes when Liddle scored his first goal of the season by powerfully heading home a Neil Austin free-kick.
The visitors dominated the first half and they were only denied a second goal when Peter Clarke cleared Adam Boyd's goal-bound shot off the line.
But the Terriers responded with a commanding performance after the break. Pilkington rattled the bar with another free-kick and substitute Theo Robinson missed an open goal as Town turned the screw.