Brave York withstood almost constant Rotherham pressure to grab a 1-0 victory with a late winner.
The Millers did most of the early attacking and after 10 minutes Mark Bradley's cross-cum-shot landed on the roof of the net. Bradley was forced off 10 minutes later and replaced by David Noble.
York goalkeeper Michael Ingham was forced to handle a backpass in the 27th minute but the defensive wall did its job and five minutes later Rotherham came within a whisker of the opener when Alex Revell's shot deflected off a defender but Kieran Agard could not get a foot to the ball to turn it into the net.
At the other end, Andy Warrington saved easily from Chris Smith - York's only first-half shot on target - while Ingham was at full-stretch to tip over Jason Taylor's effort.
York started brightly after the break but again it was Rotherham who went close with a brace of headers by Johnny Mullins from Gareth Evans corners, the first scrambled clear by Ingham and the second landing on the roof of the net. Ingham then pulled off a great save to deny Revell.
And with 10 minutes to go York grabbed the lead. Jason Walker's shot was blocked by Ian Sharps, but the ball fell straight to Matty Blair and he swept home.
A brilliant save by Ingham from substitute Daniel Nardiello's diving header ensured York's victory.