The 30-year-old, born in Kent, arrived at Priestfield in the summer of 2023 having turned down a new deal with Swindon Town.
The former Welsh international played 49 times and scored one goal during his debut season with the Gills, that coming in an EFL Trophy tie at Portsmouth.
Williams had previously played for Ipswich, Nottingham Forest, MK Dons, Sunderland, Charlton, Cardiff and, most notably, for Crystal Palace during their time in the Premier League.
He represented his country on 33 occasions having also featured for the U17, U19 and U21 sides.