Two goals in a minute from James Pearson and Emmanuel Sonupe put Harriers in the driving seat at half time.
York, the current Trophy holders, were much improved in the second period and Amari Morgan-Smith got the Minstermen back into it with a quarter of an hour left.
But Harriers just about held on, extending their recent good form at home, much to the delight of Gardiner.
“That’s a criticism that has been levelled at us before,” he said when asked about the difficulty his side face closing games out.
“They’re a young group and still learning. To be as competitive as we were in the final stages and to get over the line was very pleasing.
“We weren’t as fluid as we normally are on the ball but you have to give York credit for that.
“They came here and gave a good account of themselves. The aim at the start of the day was to make it through and we have.
“We defended really well today. There were some strong performances, especially the two centre-backs, and we got over the line.”
For more news, reaction and action from across the National League, like us on Facebook and follow us on Twitter and Instagram.