The 28-year-old, who was born in Bilbao to Ghanaian parents, has played for the Spain Under-21 side and also made one appearance for the senior team in a friendly against Bosnia in 2016.
- La Liga on ESPN+: Stream LIVE games and replays (U.S. only)
- Don't have ESPN? Get instant access
"Every step we take forward has its own meaning... a glance into the future which leaves a trace itself. A legacy. My parents have raised me with values based on humility, respect and love," Williams said in a video posted on social media.
"That's why I feel the moment has come for me to find my origins within myself and with Africa and Ghana which means so much to me and my family."
Ghana Football Association president Kurt Okraku tweeted that Brighton & Hove Albion's Tariq Lamptey was also available for selection. The 21-year-old right back has been a youth international for England.
FIFA rules stipulate that players can switch countries if they have not played more than three matches for a country before the age of 21 and have not featured in a World Cup or continental tournament.
Williams holds the LaLiga record for consecutive appearances -- 233 games -- after bettering the previous mark of 202 in October.