Aiyegbeni Yakubu converted Patrik Berger's cross shortly after half-time to score the game's only goal as Portsmouth went through in the FA Cup.
Yakubu almost scored after two minutes, but was denied by goalkeeper Steve Banks, who also did well to deny David Unsworth and the impressive Berger.
Diomansy Kamara and Berger also hit the woodwork for Pompey.
The Gills had chances and Pompey keeper Jamie Ashdown did well to save from Darius Henderson and Andy Hessenthaler.
Henderson came especially close to scoring, his 25-yarder midway through the first-half saved by Ashdown.
Shortly afterwards Berger linked up with Yakubu before drilling his shot against the post from 15 yards.
Ashdown's brave advance stopped Hessenthaler after the midfielder was put through by a fine pass from newcomer Matt Bodkin.
Yakubu missed twice more before the break while record signing Kamara, jeered for regularly giving the ball away, scuffed an inviting chance set up by Andy Griffin.
At the start of the second half however, Kamara hit the target only to see Banks palm his shot against the post. forcing Banks to turn his shot against the bar.
Pompey almost increased their lead after Yakubu put them in front but Banks twice denied Berger.
Portsmouth coach Joe Jordan:
"It was a goal. No doubt. I thought we would score at the start of the second half. A lot of opportunities came and we could have finished the game in that spell.
"Anything can happen when it is 1-0 but we were in control.
"The strikers kept it simpler in the second half and although we didn't score again to put it beyond Gillingham, I didn't think they would score."
Gillingham boss Stan Ternent:
"It was offside but then again I suppose it wasn't because the linesman did not flag for it.
"We have gone out with our heads held high because we had a lot of injuries and it was always going to be tough because Portsmouth are a strong team.
"We had a couple of chances in the first half and gave them a few problems but just one in the second period when Iwan Roberts could not make the most of it."