Luke Croll struck late on as Eastleigh eased their National League relegation worries by deepening those of nine-man York.
City started brightly and Eastleigh goalkeeper Joe McDonnell had to palm away a Maz Kouhyar effort before Marvin Armstrong hit the bar.
McDonnell came to the rescue once again as half-time approached, tipping Armstrong’s shot over.
Scott Quigley then headed against the woodwork after George Langston had flicked on Paul McCallum’s long throw with the Spitfires pressing.
The visitors received a double boost as time ran down when Zanda Siziba was sent off for a challenge on Solomon Nwabuokei and then Ryan Fallowfield, who had been cautioned for his protests, followed him within minutes for a second bookable offence.
Eastleigh finally forced their way ahead with seven minutes remaining when Croll stabbed home from close range after Quigley had helped on Ben Reeves’ corner.