Peter Duffield stepped up to score a late controversial penalty to give York their first away win of the season against a battling Swansea side.
The veteran striker notched his sixth goal in six games past Swansea keeper Roger Freestone after referee Phil Crosser had awarded a penalty for a foul by Andrew Mumford.
Mumford had appeared to push the in-form Duffield as the ball was travelling out of the Swansea area.
York manager Terry Dolan said: "Everybody was adamant it was a penalty - even the boys on the Swansea bench couldn't believe Mumford had fallen for it."
The Minstermen controlled the game for most of the match and looked comfortable against a hard-working Swansea side that lacked quality.
Swansea started brightly with Lee Jenkins twice going close in the first five minutes.
However, York hit back and they deservedly took the lead when the 21-year-old midfielder Lee Bullock stabbed the ball home after 31 minutes from a scrambled corner by Graham Potter.
Swansea pushed men forward in the second half reverting to a 5-3-2 formation and eventually got the equaliser when David Moss nodded Michael Howard's cross home in the 75th minute.
Terry Dolan's men scored the winner late in the second half following the needless foul by Mumford on Duffield.
Swansea player-manager Nick Cusack, starting his first game up front this season said: "The least we should have got out of the game was a point "I told my players to keep their heads up because they deserved better. The results will come."
York City manager Terry Dolan said: "You just can't keep Duffield down. He's been on a fantastic run. Once the penalty was awarded there was only ever one player on the pitch that was going to take it."
Duffield is now only one goal away from beating the club's consecutive goalscoring record