Wrexham reached the first round proper of the FA Cup after York City defender David McGurk scored a late own goal.
McGurk diverted a low, driven cross from Wrexham player-manager Andy Morrell into his own net on 81 minutes.
The home side had taken the lead five minutes into the second half when captain Nat Knight-Percival headed in from Johnny Hunt's cross.
York responded with a superb Patrick McLaughlin free-kick, but McGurk's blunder sent Wrexham through.
Morrell has now guided the Dragons to seven wins from his nine games as interim manager, and immediately following the game, the club announced that 37-year-old had been appointed as manager until the end of the season.
The process to appoint Dean Saunders' successor had been delayed by the continuing doubt over the proposed takeover by the Wrexham Supporters Trust.
The Trust had wanted to appoint their own man after taking control of the club, but the prospective owners have given their full backing to Morrell's appointment.
VIEW FROM THE DRESSING ROOM:
Wrexham manager Andy Morrell told BBC Radio Wales:
"I thought we were ahead on points at half-time but lacked that quality in the final third to get that goal that I thought we deserved.
"We then scored a really good goal after a great cross from Johnny Hunt. We lost our shape a bit when they scored and that's something we'll have to address.
"But the subs came on and did their job and we managed to nick a winner."
Wrexham: Mayebi, Obeng, Ashton, Creighton, Harris, Cieslewicz, Speight, Hunt, Knight-Percival, Pogba, Clarke.
Subs: Maxwell, Fowler, Wright, Clowes, Little, Westwood, Morrell.
York: Ingham, Oyebanjo, Meredith, McGurk, Parslow, Reed, Kerr, Henderson, Potts, Moke, McLaughlin.
Subs: Musselwhite, Smith, Chambers, Boucaud, Fyfield, Blair, Challinor.
Referee: I Simpson (England).