A downcast Portsmouth manager, Alain Perrin, admitted that the reaction of the travelling support, who made their feelings clear as he walked off, was justified.
"For the fans to be angry is normal," said the Frenchman. "They expected a win and everyone is very disappointed. We gave away some bad goals and this gave confidence to Gillingham and they beat us."
Gillingham, without a win in five games - they had failed to score in the last three - were immediately under pressure and seven minutes in, their visitors had already struck the crossbar through the winger Matthew Taylor.
Unperturbed by this, Gillingham continued to play attractive, and at times, adventurous football against the Premiership side. But, on 24 minutes, Gary O'Neil put Pompey ahead after the Uruguayan striker Dario Silva pulled the ball back for the midfielder.
Gillingham equalised three minutes before the interval in controversial circumstances. Darren Byfield, waiting on the touchline to be signalled back on, intercepted a throw from Jamie Ashdown and fired powerfully past the Portsmouth goalkeeper. Portsmouth's protestations, that Byfield had not been waved on, fell on deaf ears.
Gillingham came out for the second half in confident mood but, two minutes in, they were behind. O'Neil was fouled by Brent Sacho in the penalty area, with Taylor confidently stroking home the resulting penalty.
However, on 54 minutes, Byfield again drew Gillingham level, again fortuitously. His 20-yard shot struck the post with the rebounding ball hitting Ashdown on the back of the head before crossing the line.
Substitute Svetoslav Todorov earned Portsmouth the chance of salvation five minutes from time after tumbling under Sancho's tired-looking challenge, but the striker's spot kick flew wide of Jason Brown's goal as the game went into extra time.
The Gillingham midfielder Andrew Crofts struck the killer blow three minutes into the first period, a defence in disarray failing to stop Danny Jackman as he pulled the ball into the path of the Welsh Under-21 international, who thumped it home.
Portsmouth looked drained, their energy spent as their fightback failed to materialise and the Gillingham manager, Neale Cooper, was left to savour a superb effort from his side. He said: "It was a special night and a fantastic performance from the players."
Gillingham: (4-4-2) Brown; Sancho, Rose, Hope (Jackman, 76), Johnson; Hessenthaler (Williams, 65), Crofts, Flynn, Jarvis; Byfield, Shields (Hislop, 112). Substitutes not used: Crichton, Pouton.
Portsmouth: (4-4-2) Ashdown; Stefanovic, Priske, O'Brien, Vignal; Taylor (Viafara, 105), O'Neil, Diao (Songo'o, 69), Hughes; Karadas, Silva (Todorov, 62). Substitutes not used: Westerveld, Skopelitis.
Referee: A Bates (Staffordshire).
- More about: