City fought back from the shock of conceding an early goal but were undone by Paul Smith's 70th minute winner at Priestfield Stadium.
The Gills' midfielder's sweetly-struck 18-yarder twenty minutes from time proved decisive and the home side survived frantic late pressure as the Potters battled to protect a six-match unbeaten league run.
Kenwyne Jones nearly grabbed a second equaliser but was denied by a superb save by former City 'keeper Steve Banks.
It was Jones who levelled in the 54th minute when he darted in front of Banks to head home Dave Brammer's cross.
That came after Gillingham took the lead after just 90 seconds with a fluke goal when James McElevey's curled free-kick from just inside the touchline evaded attempted clearances and crept into the net.
In an edgy start, City could have fallen further behind in the fourth minute when Michael Flynn seized on poor defensive work but shot wide.
Nicky Southall headed over and Steve Simonsen punched away a Flynn free-kick as the home side dominated.
The Potters were brought to life after 27 minutes when Clive Clarke thumped a 20-yard free-kick against the crossbar and Gifton Noel-Williams was denied an 11th goal of the season just before the interval when his shot was blocked.
City took control after Jones grabbed the second goal of his loan spell from Southampton and Smith's strike was against the run of play.
In a tense finish Wayne Thomas was almost the saviour in injury time when he burst through but substitute goalkeeper Bertrand Bossu denied him.
Gillingham: Banks (Bossu 76), Nosworthy, Hope, Cox, McElevey, Southall, Smith, Douglas, Flynn, Sidibe, Henderson (Byfield 64). Subs: Hills, Jarvis, Crofts.
City: Simonsen, Thomas, Duberry, Taggart (Buxton 86) Hill, Harper, Brammer, Russell, Clarke (Greenacre 83), Noel-Williams (Ricketts 80), Jones. Subs: De Goey, Henry.