John-Joe O'Toole fired in at the far post to give Bristol Rovers their first win of the season after a Ryan Jarvis brace had pulled 10-man York level.
The Pirates led 2-0 when David Clarkson volleyed home a clearance before poking in when Michael Ingham dropped a cross.
Jarvis levelled the game, scoring a rebound and a penalty either side of York striker Ryan Bowman being sent off for a skirmish with Rovers' Tom Parkes.
However, O'Toole ghosted onto Alfie Santos's drilled ball to steal victory.
VIEW FROM THE DRESSING ROOM
York City manager Nigel Worthington told BBC Radio York:
"In the second half we were excellent with 10 men, we out-powered them, we out-ran them and scored a great goal.
"But we cannot start a game like that - to be 2-0 down through two soft goals gave us a mountain to climb.
''Regardless of what happened [to Ryan Bowman] you cannot lift your hands - the rule is you lift your hands and you're sent off.
"Discipline is something I and the team pride ourselves on. The situation will be dealt with internally and we'll move on from there."
Sorry, we were unable to load match stats, please try again.