The 32-year-old, formerly of Wigan and Ipswich, joined the Eagles in the summer of 2010 and has made 57 appearances in all competitions, including 25 starts last term.
However, he has managed just one Capital One Cup start and two substitute appearances this season.
Gills boss Martin Allen told the club's official website: "David will go straight into our squad for Saturday's game against Bristol Rovers.
"He can play in midfield or anywhere in defence and is another good senior player with a good work ethic to add to our squad.
"There will be no more signings in the foreseeable future."
Jordan Rhodes is the star guest on this week's Football League Hour on Sky Sports News Radio. Bournemouth boss Paul Groves also joins hosts Dean Windass and Mikey Burrows with Blackpool's Kevin Phillips taking the Quickfire Quiz. Tune in Thursday from 7pm at skysports.com/radio or via the Sky Sports News apps.