Marshall, a pacey and tricky winger by trade, was released by Gillingham on Thursday and becomes Keith Curle’s first signing since the transfer window opened on New Year’s Day.
Other clubs were rumoured to be interested in his services, including League One sides Blackpool and Wycombe Wanderers, but Cobblers have won the race for his signature.
The 32-year-old joined Gillingham in the summer and made 23 appearances in all competitions , the last of which coming as a second-half substitute against West Ham United in the FA Cup third round earlier in the month.