Pompey left it late to book their spot in the third round of the Emirates FA Cup.
Brett Pitman stooped to head home deep into stoppage-time and secure a 2-1 victory over Altrincham at Fratton Park.
The hosts had earlier gone ahead through Ben Close's fine volley, only for Josh Hancock to level from the penalty spot.