The victory was the Minstermen’s first in seven matches with Jordan Burrow bagging a brace either side of Lewis Hawkins’ first goal for the club.
Lee Vaughan replied for the Harriers, who also had a penalty by Ed Williams, currently being monitored by Leeds United, saved by Adam Bartlett.
York were 2-0 to the good by the half-way point courtesy of close-range efforts from Burrow and Hawkins.
On-loan Rotherham winger Alex Bray was then fouled by Fraser Horsfall for a 51st-minute penalty, despatched by Burrow.
Vaughan went on to net from eight yards before Bartlett denied Williams from the spot after Bray had collided into Kane Richards.
Elsewhere, Farsley Celtic caused a shock as first-half goals from Nathan Cartman and Jimmy Spencer secured a 2-0 triumph at National League North hosts Alfreton.
Bradford Park Avenue crashed out 4-0 at Altrincham, though, with John Johnston opening the scoring from the spot after Danny Lowe had floored Jordan Hulme.
Hulme doubled the lead, Josh Hancock curled in from the edge of the box and Kallum Mantack rounded off the scoring.
Guiseley forced a replay in stoppage time at Northern Premier League Lancaster City thanks to Will Thornton’s header.
Craig Stanley and Rob Wilson had earlier given Lancaster the lead twice, either side of a Rowan Liburd tap-in.
Marske United went out 4-1 at Blyth Spartans, with Dan Maguire hitting a hat-trick for the hosts and Robbie Dale converting from the spot.
But the Seasiders didn’t go out without a fight.
Chay Liddle reduced the deficit to 2-1 just before the break, Josh Rowbotham saw a header cleared off the line and James Fairley rattled the crossbar.
Pickering Town will travel to Ramsbottom for a replay after Ryan Blott and Billy Logan both hit uprights while Josh Greening had a shot cleared off the line and an effort disallowed in a 0-0 draw.