Highlights: York City 0-1 Altrincham
York's 19-game unbeaten run ended as Altrincham booked their place in the FA Cup second round with victory at Bootham Crescent.
The visitors saw their goalkeeper Tony Thompson pull off a fine save from Andy Bond's penalty just after half-time.
And it got better for Altrincham when Tom Peers snatched the only goal late on to beat the National League leaders.
Peers had gone close in the first half, but was foiled by the onrushing home keeper Peter Jameson.
York had been slow to get out of the traps, but they fashioned the half's best opportunity when Sean Newton saw his free-kick crash back off the crossbar.
Altrincham looked lively upon the restart, but it was the hosts who were handed a golden chance to open the scoring when Thompson clumsily fouled Dan Maguire to concede a penalty.
But Thompson atoned for his error quickly, diving to his right to keep out Bond's spot-kick.
The ball bounced straight back into play, but York somehow scuffed a shot that came back off the bar as Altrincham miraculously escaped.
And that proved crucial eight minutes from time when they snatched the victory.
Substitute Toby Mullarkey played the ball into Peers and he coolly picked his spot to beat Jameson.
Match report supplied by PA Media.
York manager Steve Watson:
"We didn't create anywhere near enough with the ball. If you miss a penalty then you get the feeling that it isn't going to be your day.
"I take the FA Cup very seriously but from a selfish point of view as a manager, I'd rather have our first defeat come in the cup. It's a tough season."
Altrincham boss Phil Parkinson:
"To come to an unbeaten team and get through is brilliant, especially after conceding the penalty.
"The message to the players is that as happy as we are with this cup win, we've a lot of catching up to do in the league.
"It would be fantastic if we can go again and get through to the third round, but we'll have to wait and see."