Rotherham had to produce a rallying performance to see off Crewe 2-1 in their Carabao Cup first-round tie.
Steve Evans’ Millers had fallen behind in the second half to a Matus Holicek goal but Sam Nombe equalised and substitute Hakeem Odoffin won it for the hosts in the 86th minute.
Rotherham missed a host of first half chances with Jonson Clarke-Harris close on two occasions to netting for the first time since his return to the New York Stadium.
Defenders Jamie McCart and Sean Raggett should also have hit the target with close-range openings and Joe Powell stung the palms of Filip Marschall with a powerful free-kick.
At the other end, Cameron Dawson, on his Rotherham debut, produced a stunning save to keep out Jack Lankester’s snapshot for League Two Crewe.
The League One hosts were left ruing their wastefulness when they fell behind in the 50th minute after Alex MacDonald’s mistimed header was snatched upon by Holicek, who bent his shot beyond Dawson.
Rotherham were level five minutes later when Powell stood up a cross for Nombe to nod home.
Odoffin was brought off the bench by Evans and he was in the right place to tap home the winner after Clarke-Harris had nodded back across the box.