Striker Ryan Jarvis scored on his league debut to hand York victory over 10-man Northampton.
The Cobblers had gone closest when Ray O'Donovan's shot crashed against the underside of the crossbar.
There was more misfortune for the visitors when, with 18 minutes to go, Darren Carter collected his second yellow for a foul on goal hero Jarvis.
Jarvis was to have the final say, converting a Richard Cresswell knockdown just before the whistle.
VIEWS FROM THE DRESSING ROOM
York City manager Nigel Worthington told BBC Radio York:
"The game is 90 minutes plus nowadays and as long as we say to the players keep going until the final whistle win lose or draw and we have done that in good style.
"Over the course of the game what we achieved in that period of time. We deserved to win the game through some very good play.
"What pleased me most was the competitive side. We matched them physically and didn't get caught up with dismissing the ball easily.
"We kept our heads and passed it and managed to make some very good opportunities for their keeper to make one or two very good saves."
Northampton Town manager Aidy Boothroyd told BBC Radio Northampton:
"I thought it was a typical game at the start of the season, everybody finding their feet.
"We showed we're at the start of the season, while the workrate and energy was there, what I didn't think was there was that final ball in the first half.
"I thought it was a scrappy goal. In the second half I thought we had the better of the chances.
"Even with Darren's sending off I thought we had enough to take a point at a difficult place."