The 24-year-old turned down the offer of a new deal at Newport to team back up with Gills boss Justin Edinburgh.
Edinburgh signed Jackson on a free transfer from Macclesfield in July 2013 when he was in charge at Rodney Parade.
“I am delighted to get Ryan on board,” Edinburgh told the club’s official website.
“He was an excellent performer during my time with Newport and I look forward to working with him once again here at Gillingham.”
Jackson added: “I can’t wait to get started and I’ve worked with Justin before so he knows how to get the best out of me.”
Right-back Jackson has made 174 appearances during his professional career and becomes Gillingham’s third summer signing after the arrivals of Elliott List and Emanuel Osadebe.