In a hectic opening quarter-of-an-hour, City took charge with two goals from Jon Parkin.
Sean Newton's long seventh-minute throw-in was headed on by Vadaine Oliver for Parkin to volley home at the far post, and the striker then finished off a similar move with another close-range finish six minutes later.
York keeper Kyle Letheren had a moment to forget when he failed to deal with Ross Stearn's simple in-swinging free-kick and allowed the ball to bounce between his legs into the back of the net.
After the break, Spitfires defender Gavin Hoyte somehow cleared Amari Morgan-Smith's close-range shot off the line.
Substitute Tyler Garratt then hit the post at the other end with a bouncing 25-yard drive.
Oliver nearly restored York's two-goal lead when his header from an Asa Hall corner was pushed against the bar by keeper Ryan Clarke.
But the striker was not to be denied as he wrapped up the points with 10 minutes left, holding off Ayo Obileye's challenge before steering a shot into the bottom corner.
Match report supplied by the Press Association.
Match ends, York City 3, Eastleigh 1.
Second Half ends, York City 3, Eastleigh 1.
Ayo Obileye (Eastleigh) is shown the yellow card.
Substitution, York City. Danny Holmes replaces Adriano Moke.
Reda Johnson (Eastleigh) is shown the yellow card.
Substitution, Eastleigh. Sam Matthews replaces Ben Close.
Goal!  York City 3, Eastleigh 1. Vadaine Oliver (York City).
Substitution, Eastleigh. Scott Wilson replaces Craig McAllister.
Simon Heslop (York City) is shown the yellow card.
Substitution, Eastleigh. Tyler Garrett replaces Ross Stearn.
Second Half begins York City 2, Eastleigh 1.
First Half ends, York City 2, Eastleigh 1.
Goal!  York City 2, Eastleigh 1. Ross Stearn (Eastleigh).
Goal!  York City 2, Eastleigh 0. Jon Parkin (York City).
Goal!  York City 1, Eastleigh 0. Jon Parkin (York City).
First Half begins.
Lineups are announced and players are warming up.
York climbed off the foot of the National League with an impressive win to leave Eastleigh still chasing their first win of the year.