The 27-year-old previously spent two seasons with the Glovers during which time he scored 22 times in 72 appearances before leaving for Wiltshire in 2012.
Having also had spells with Hereford and Bristol Rovers, Williams returns to Huish Park much to the delight of his new manager Gary Johnson.
"I am delighted everything has come together and we welcome back with open arms Andy back to Yeovil," the 57-year-old told the club's official website.
" We have some very good strikers already at the club but we all know in the Championship you can't have enough goal scorers.
"I'm sure the odd one or two fans may have felt aggrieved that Andy left to join Swindon but he felt it was the right move for him at the time."
Williams will join up with his new team-mates ahead of Saturday's clash at home to Derby.