It was York's eighth successive league victory, beating the seven in a row by York's 1965 Division Four promotion-winning team.
The Minstermen's huge improvement after narrowly escaping relegation last April is underlined by the remarkable statistic that they have now gathered 52 points, the same number as in the whole of last season, with 20 matches still remaining.
Leading scorer Richard Brodie took his total to 27 with a brace of goals, watched by Ricky Sbragia, the former Sunderland manager and now their chief scout.
Brodie made York's first goal on 25 minutes with an accurate pass for Chris Carruthers to score. Carruthers returned the favour two minutes after the break with an inswinging free kick which England C international Brodie nudged home.
Hayes were reduced to 10 men when Tom Cadmore was sent off for tripping Brodie just outside the penalty area after 51 minutes and seven minutes later Brodie cleverly chipped the ball into an empty net with goalkeeper Simon Overland stranded 20 yards out.
Michael Gash hit the post before Kevin Gall made it 4-0 in the 83rd-minute from a pass from Carruthers. Scott Fitzgerald reduced the deficit for Hayes in stoppage time.
"A great day for the club. Our passing, movement and balls into the channels was excellent," said manager Martin Foyle.
York City: Ingham; Parslow (Purkiss 67), Graham, McGurk, Meredith; Lawless, Barrett, Mackin, Carruthers; Brodie (Gall 59), Rankine (Gash 59). Unused substitutes: Smith, Ferrell.
Hayes & Yeading United: Overland; Allen-Page, Cadmore, Ruby, Green; Binns (El-Abd 53), Marwa, Canham, Little (Fitzgerald 67); James, Basham (Palmer 77). Unused substitutes: Gradwell, Baker.
Referee: P Curry (Ashington).
Man of the match: Chris Carruthers.