The Minstermen went out of at the first-round stage following three National League North losses in eight days, but they were just 14 minutes away from earning a replay before Steven Alzante scored the winning goal for Phil Brown’s men.
But despite the victory, former Hull City boss Brown was sacked by Town last night, with the 17th-placed in League 2, having won just one of their last eight matches.
Home midfielder Scott Twine had opened the scoring on Saturday, only for visiting left-back David Ferguson to level the tie on the stroke of half-time with his second goal of the season.
Twine drew first blood on 12 minutes after a clever flick of his heel saw the ball roll in off the inside of goalkeeper Adam Bartlett’s far post following Jermaine McGlashan’s low right-wing cross into the six-yard area.
Moments later, Twine hit an upright after clever individual play had teed up a volley for himself.
The Minstermen rallied and, on 43 minutes, former England C international Ferguson swept the ball home after Jordan Burrow’s header had been saved by Robins goalkeeper Lawrence Vigouroux.
There were subsequent second-half chances for Kallum Griffiths, Burrow and Nathan Dyer, but Alzante snuffed out hopes of an upset when he steered in from eight yards with the aid of a deflection off York debutant Joe Davis following Keshi Anderson’s right-wing raid.
Swindon Town: Vigouroux, Woolfenden, Nelson, Conroy, McGlashan (Knoyle 88), Iandolo, Dunne, Alzate, Anderson, Twine, Adebayo. Unused substitutes: Smith, Young, McCormick, Taylor, McCourt, Lancashire.
York City: Bartlett, Law (Harris 61), Davis, Newton, Dyer (Parkin 80), Hawkins, Griffiths, Moke, Ferguson, Burrow, Bray (Langstaff 80). Unused substitutes: Bencherif, Wright, Whitley, Harrison.
Referee: C Brook (East Sussex).