Mo Harkin's first-half goal sent Havant into the FA Cup second round for the first time in their history.
Harkin scored for the Blue Square South side after 24 minutes, racing on to Jamie Slabber's pass to score.
York dominated throughout, but could not find a way through and missed a succession of chances.
Onome Sodje's bicycle kick was just off target and keeper Kevin Scriven saved well from Martyn Woodward late on as York were denied again.
York: Evans, Craddock, McGurk, Kelly (Rhodes 85), Robinson, Brayson (Brodie 31), Elliott (Wroe 75), Panther, Woolford, Sodje , Farrell.
Subs Not Used: Mimms, Parslow.
Havant and W: Scriven, Smith, Jordan, Sharp, Poate, Harkin, Collins, Oatway (Wilkinson 75), Taggart (Gregory 59), Baptiste, Slabber (Pacquette 37).
Subs Not Used: Taylor, Potter.
Booked: Oatway, Collins, Pacquette.
Goals: Harkin 24.
Ref: Russell Fletcher (Derby).