The Wales defender, who only signed a three-year deal 12 months ago, was linked with moves to Liverpool and Newcastle in the summer.
"I'm delighted to get it signed," said Williams.
"It's dragged on a bit, but I'm happy to finally sign and be part of this team.
"I'm enjoying it here. It's a great place to be at the moment."