The 29-year-old had only a year remaining on his previous deal and had been a summer target for Sunderland, who are understood to have had a number of offers rejected.
The defender's agent, Jamie Moralee, revealed earlier this week that Swansea had told Williams he would not be leaving the club during the summer transfer window.
Moralee hinted that the Wales international was keen to extend his stay at the Liberty Stadium, and the speculation over his future has now ended after he signed a new four-year contract.
The club captain, who has made over 250 appearances for Swansea since joining in 2008, revealed his delight at securing the new deal ahead of Swansea's pre-season tour of the United States.
“I’m delighted to sign a new contract at Swansea City,” Williams told the club's official website. “I’ve enjoyed fantastic success at this club and I want to keep helping Swansea City progress.
"There seems to a lot of talk every summer but I was quite relaxed. I always knew where I wanted to be. It was just a matter of working things out.
"I've been here six years and this is home to me I didn't want to go anywhere else. I'm happy, I know Swansea and they know me. I'm just pleased to get it all sorted so early in the pre-season so I can just get my head down and kick on."
Manager Garry Monk was equally pleased with the news that he can call on his defensive lynchpin for the foreseeable future.
"He's an important player, the captain of his club and country," he told Sky Sports News. "I've said from the start that I have got a good relationship with Ashley, he is an integral part of this club, stabnds for a lot of the values that this club represents; it is important that we keep these sort of players at the club.
"It's definitely one of the biggest signings we could have had. I explained to him exactly how we planned to go forward it's important that he understands how I work and how we want to take the club forward; he wants to be part of that and buys into that whole way of working.
"I spoke to him from day one, of course you have interest form elsewhere; you get agents in your ear telling you this and that but Ashley always wanted to be here, deep down in his heart. Fortunately, we have managed to come to an agreement and it is great to have him."