The burly 31-year-old striker was deemed surplus to requirements at Sixfields following the Cobblers' League Two play-off final defeat to Bradford.
But Akinfenwa will be playing third-tier football next term with League Two champions Gills, whom he previously joined in 2010 from Northampton and enjoyed a single season before returning to Sixfields in 2011.
The frontman bagged 11 goals in 46 appearances during his last stay at Priestfield.
Manager Martin Allen told the club's official website: "We have signed Bayo Akinfenwa, whose goal ratio over the last two years of 34 goals from 63 appearances is outstanding.
"He has signed a one-year contract and it is my gut feeling that he will do well in a Gillingham shirt, playing for the club that he loves.
"Opposition teams cannot handle him, or deal with him, and I'm sure, with the passion of our supporters, that he will respond on the big stage called Priestfield.
"I have given him squad number 19 and he will be a very valuable member of our squad, on and off-the-field."