York City beat Portsmouth at Bootham Crescent to register their first win since the opening day of the season.
Wes Fletcher's early strike put York up at the break after John Sullivan spilled Josh Carson's free-kick.
Pompey levelled eight minutes after the restart through Jed Wallace, only for Sullivan to gift Lewis Montrose an easy tap-in to put York back in front.
Ryan Jarvis then found the corner and Fletcher headed York's fourth, John Marquis netting Pompey's late second.
York's match-winning burst of three goals in six second-half minutes lifts them three points clear of the League Two drop zone, to within a point of 17th-placed Pompey.
VIEWS FROM THE DRESSING ROOM
York City manager Nigel Worthington told BBC Radio York
"I'm delighted with the display, more so the result, from start to finish.
"It was a good all round solid performance. We did what we had to do.
"It was interesting when they got the equaliser what the response would be and we stayed positive and kept driving at the game.
"I think probably for the first time this season we've had a little rub of the green."
Portsmouth manager Guy Whittingham told BBC Radio Solent:
"It was a poor performance. You can protect people so much if you feel that they've given their all. Today we didn't give our all and I've got to say that's the first time it's happened and it's got to be the last time.
"It started right from the first minute; we didn't go and win a header, they're suddenly on top of us.
"All you ever want to see from players, our players, is that desire; desire to do well and desire for hard work and their hard work was much more than ours today and that's what's cost us the game.
"It's not a case of playing well or not playing well, it's that desire to work hard and we didn't have that today."