Steve Bruce's men created the better chances but the National League North side gave a good account of themselves and former Magpie Steve Watson - the Minstermen's manager - will be pleased with how his team competed against a strong United side, even before Michael Duckworth got the only goal of the game three minutes from the end.
With Karl Darlow testing positive for Covid-19 earlier in the week and Freddie Woodman and Mark Gillespie self-isolating having been identified as close contacts, 20-year-old Dan Langley was given his Magpies debut in goal with 16-year-old Max Thompson on the bench.
But neither Langley nor his opposite number, Ryan Whitley, were tested in the opening exchanges of the first half until, in the 20th minute, Dwight Gayle - on for the injured Joelinton - found the run of Ryan Fraser, who attempted to lift the ball over Whitley but saw his effort hit the outside of a post.
Three minutes later, Langley made a fine save to deny full-back Duckworth before Whitley pulled off an even better stop at the other end on the half-hour mark, blocking Jacob Murphy's header from point-blank range after a deep cross from Matt Ritchie.
With the Magpies now beginning to find some rhythm, they fashioned another half-chance when Kell Watts brought the ball out of defence and teed up Fraser, whose cross was met by the head of Callum Wilson, but last season's leading scorer couldn't generate enough power to beat Whitley.
Great defending from Scott Barrow and ex-United under-23s man Patrick McLaughlin then thwarted Wilson, with both throwing themselves simultaneously in the way of the number nine's shot after a fine turn from the England international.
Another former Magpies youngster, Mackenzie Heaney, squandered a good opportunity for the hosts before Jeff Hendrick saw a low shot saved just before the break.
Watts made a vital block from a York trialist just after the hour as both teams made a raft of changes in the second period.
One of the substitutes, Allan Saint-Maximin, almost forced an opener when he made space for a cross on the right and Olly Dyson, facing towards his own goal, made Whitley work to keep out his attempted interception.
Gayle and Ritchie both had opportunities for United before Saint-Maximin ran through but saw his effort blocked by Josh King.
Then the resulting corner was only half-cleared with Sean Longstaff hitting the side-netting as Newcastle kept the pressure on.
But York almost snatched an unlikely winner as Barrow's effort was deflected just wide in the closing stages.
And they did get the only goal of the game in the 87th minute, when Duckworth's towering header gave Langley no chance, ending the rookie goalkeeper's hopes of a debut clean sheet and delighting the home crowd - while leaving Newcastle with plenty to improve on ahead of Friday's trip to Doncaster Rovers.
Newcastle United: Dan Langley, Jacob Murphy, Jamaal Lascelles (c) (Jamal Lewis 46), Federico Fernández (Paul Dummett 68), Kell Watts, Isaac Hayden, Ryan Fraser (Matty Longstaff 60), Jeff Hendrick (Sean Longstaff 60), Callum Wilson (Allan Saint-Maximin 46), Joelinton (Dwight Gayle 18, Yoshinori Muto 79)
Subs not used: Max Thompson, Ciaran Clark