Match ends, Accrington Stanley 3, York City 2.
Jackie McNamara suffered defeat in his first game as York manager as Accrington progressed to the second round of the FA Cup.
Sean McConville shot in off the post to put Stanley ahead but Vadaine Oliver soon tapped in to level.
Matt Crooks fired Accrington back in front after a stunning solo run, before Josh Windass secured victory from the spot after Billy Kee was fouled.
Michael Coulson's header late on was only a consolation for City.
York City manager Jackie McNamara told BBC Radio York:
"I thought some things were pleasing but from my point of view I thought the goals we lost were very poor. They were too easy.
"You can understand why we haven't won in 10.
"From middle to front we look a threat when we do things properly and quickly but defensively I think we play as individuals which we need to sort out quickly."
- 29KeeBooked at 73mins
- 8WindassSubstituted forGornellat 88'minutes
- 15LoweSubstituted forWinfieldat 45'minutesBooked at 74mins
- 3IlesanmiBooked at 61mins
- 26GodfreySubstituted forTurnerat 77'minutes
- 29SinclairSubstituted forHydeat 59'minutes
- 9OliverBooked at 28mins
- Fred Graham
- Shots on Target
Second Half ends, Accrington Stanley 3, York City 2.
Femi Ilesanmi (York City) wins a free kick on the right wing.
Foul by Billy Kee (Accrington Stanley).
Foul by Femi Ilesanmi (York City).
Billy Kee (Accrington Stanley) wins a free kick in the defensive half.
Goal! Accrington Stanley 3, York City 2. Michael Coulson (York City) header from the right side of the six yard box to the bottom right corner. Assisted by Rhys Turner.
Attempt missed. Sean McConville (Accrington Stanley) right footed shot from the left side of the box is just a bit too high.
Piero Mingoia (Accrington Stanley) wins a free kick on the left wing.
Foul by Vadaine Oliver (York City).
Substitution, Accrington Stanley. Terry Gornell replaces Josh Windass.
Foul by Michael Collins (York City).
Sean McConville (Accrington Stanley) wins a free kick in the defensive half.
Foul by Eddie Nolan (York City).
Josh Windass (Accrington Stanley) wins a free kick on the right wing.
Attempt saved. Dave Winfield (York City) header from the left side of the six yard box is saved in the top left corner.
Corner, York City. Conceded by Tom Davies.
Corner, York City. Conceded by Brad Halliday.
Attempt missed. Brad Halliday (Accrington Stanley) right footed shot from outside the box is close, but misses to the right.
Attempt missed. Matt Crooks (Accrington Stanley) right footed shot from outside the box is too high.