The match appeared to be heading for a 1-1 draw as it entered extra-time, after Joe Morrell had cancelled out Rafa Ramos’ opener for the hosts.
However, in stoppage time, Harry Jewitt-White headed home from close range and then Destiny Ojo raced clear to make it 3-1 moments later in front of a 2,250 Privett Park crowd.
John Mousinho used 21 players, with only Will Norris completing the full 90 minutes, as he made nine substitutions of 64 minutes.
The late finale flattered Pompey, but here are our player ratings...
1. Bastian Smith - 7
A couple of early saves initially kept Gosport at bay, but eventually they found a way through. Then, in the shoot-out, saved a penalty and missed one himself. One of those who emerged with credit. Photo: Jason Brown
2. Dan Murray - 6
The midfielder was asked to play in the back three and slotted in well, proving a composed presence throughout. Comfortable on the ball and some well-time tackles. Photo: Jason Brown
3. Jack Fox - 6
(Replaced by Connor May on 57 mins) - Skippered the side, playing on the left of the back three. Pompey had to defend for long spells, but stuck to his task well. Came off with a knock, prompting the Blues to switch to a back four, a system switch which ultimately helped their cause. Photo: Jason Brown
4. Spencer Spurway - 7
Produced one wonderful acrobatic clearance off the line during the first-half when the ball seemed certain to enter the net. The oldest player in the side and physically looked more at ease than others, particularly in the air. Photo: Portsmouth FC