Rotherham United were punished fully for a disappointing second-half display as they were knocked out of the FA Cup by Crewe Alexandra through a later blow.
League One visitors Rotherham had gone in front deservedly in the first half at Gresty Road after dominating proceedings.
But their opponents from a division lower responded with two goals after the interval to progress to the second round, the game-clinching goal coming in the 89th minute.
A low-key opening period that had seen the Millers in charge was sparked into life in the 21st minute.
Will Vaulks claimed the ball and, from 20 yards, curled a beautiful shot into the net.
Top scorer Kieffer Moore looked to have doubled Rotherham’s advantage on the stroke of half-time from Joe Newell’s corner but, after talking to one of his linesmen, the referee demanded that the flag-kick should be retaken.
From a position of apparent command, the Millers were pulled back two minutes after the break when goalkeeper Richard O’Donnell hesitated over whether to come for George Cooper’s free-kick and Brad Walker glanced his header home.
Callum Ainley was then on the spot in the final stages to steer the ball past O’Donnell to complete Rotherham’s misery.
Vaulks’s free-kick had clipped the bar just after the hour mark, but the home side were doing most of the pressing and Ng shot just over.
Crewe Alexandra: Richards, Ng, Raynes, Walker, Pickering, Ainley, Lowery, Grant, Cooper, Bowery (Porter 75), Dagnall. Unused substitutes: Garratt, Bakayogo, Nolan, Kirk, Reilly, Stubbs.
Rotherham United: O’Donnell, Cummings, Ajayi, Wood (Ihiekwe 83), Emmanuel, Williams (Taylor 62), Vaulks, Potter, Newell, Ball (Towell 68), Moore. Unused substitutes: Forde, Rodak, Clarke-Harris, Yates.
Referee: Scott Oldham (Lancashire).