The Minstermen controlled midfield and a thoroughly workmanlike performance limited the hosts to just one shot on target until Nardiello's strike in the third minute of added time from substitute Ben Pringle's cross.
York's Jason Walker had a shot on target after only nine minutes but Andy Warrington in the home goal saved easily. Walker should have registered on the half hour, though, with the best chance of the half when he was clean through with only Warrington to beat, but his shot grazed the bar before going over.
At the other end it was Lee Frecklington leading the Rotherham charge, twice having shots curling just wide. Then David Noble's free-kick was saved just under the bar by Michael Ingham.
In added time, Nardiello raced clear but as Ingham came off his line he lifted his effort onto the roof of the net.
Alex Revell went close with two headers just after the break, but on 57 minutes it was the visitors who should have taken the lead when Matty Blair was clean through with only the keeper to beat but Warrington made a great save to deny him.
Five minutes later the York player had his revenge. An attempted clearance rebounded straight to Blair and this time he took the ball round Warrington and tapped into the empty net.