Nigel Worthington's side couldn't have asked for a better start as Wes Fletcher found the net in the third minute after John Sullivan could only spill Josh Carson's free-kick.
Despite Pompey's lack of chances they restored parity eight minutes after the restart through Jed Wallace as the winger cut through the heart of York's defence before producing a calm finish past Michael Ingham.
The scores would only remain level for five minutes, though, as a mistake from Sullivan gifted Lewis Montrose the easiest of chances on the line to put York back in the lead.
The goals kept on coming and soon after York had a two-goal cushion as Ryan Jarvis found the far corner with a perfectly executed drive before he turned provider for the hosts' fourth with Fletcher powerfully heading home.
John Marquis found the top corner for Portsmouth late on but it proved scant consolation.