The hosts began brightly as they sensed an opportunity to collect a league scalp and they should have taken the lead inside the opening five minutes, but Daniel Parslow blazed over after ghosting past three defenders.
Rotherham began to get a foothold in the game as the first half wore on, though, and Stephen Brogan wasted two gilt-edged chances to give the League Two side the lead. First he hit the post from Ryan Taylor’s cute header and then he dragged his shot inexplicably wide when the goal was gaping.
York came strong after the break and took a deserved lead when Chris Smith headed home from close range in the 66th minute following Rankine’s cross.
And Rankine got in on the act five minutes later after Luke Ashworth hauled him down in the area and the striker got up to stroke the resulting penalty coolly home.
Rankine put the game to bed to complete a 13-minute barrage when he cut inside and placed his shot neatly in the far corner to set up a second-round tie with Darlington, while Ronnie Moore’s men were left to contemplate a third exit to non-league opposition in the last four years.