The Minstermen had to recover from the shock of conceding inside two minutes when Andre Gray steered across goal to give their opponents the lead.
Jason Walker had a soaring header tipped over by Mark Tyler in reply before the outstanding Chris Smith hooked back a Lanre Oyebanjo free-kick and Ashley Chambers smashed home his tenth goal of the season.
Early in the second-half Matty Blair latched onto Daniel Parslow's flicked header from a long throw by Oyebanjo to fire the Minstermen ahead from six-yards. Despite strong evidence of offside, Blair's 20th goal of an incredible season was allowed to stand.
York's James Meredith soon had a chance to extend the lead but headed over when well-placed and Chambers also had a low shot saved by Tyler.
But it was Luton now pressing for an equaliser and Gray went close six-yards out while Oyebanjo twiced cleared superbly from close to the line as York defended heroically.
When the final whistle sounded manager Gary Mills fell to his knees as the York fans celebrated reclaiming their league status following an eight-year absence.