Pompey scored in the closing stages of stoppage-time to secure a dramatic victory at Gillingham.
A Michael Jacobs effort deflected off Jack Tucker and into the bottom corner to settle a tight Priestfield Stadium contest.
Danny Cowley's side earlier went close through George Hirst and Mahlon Romeo, but it looked like the contest would finish goalless before a late moment of magic secured the points.