Derby County skipper Conor Hourihane scored a stoppage-time leveller as the Rams fought back from two goals down to avoid an FA Cup first-round upset at Crewe Alexandra.
The League Two side went in front before the break when Courtney Baker-Richardson tapped in unchallenged at the back post from Rio Adebisi's quality cross from the left.
Nathaniel Mendez-Laing headed a fine opportunity over the bar for Derby and moments later Elliot Nevitt made it 2-0 to the Alex with a crisp low strike after good centre-forward play from Baker-Richardson to secure possession.
Mendez-Laing made some amends for his earlier miss when his low strike squirmed under Crewe goalkeeper Harvey Davies in the 89th minute and his low cross was then converted by Hourihane as the Rams avoided a first FA Cup first round exit since 1984-85.
The two teams will now meet again at Pride Park, with the winner going through to host League One Bristol Rovers in the second round.
It had looked like being a day to forget for Paul Warne's men, who had 33 attempts at goal, but they ultimately avoided an upset that would have put more scrutiny on his position after a mixed start to the league campaign.
The Derby boss made a quadruple substitution with around 20 minutes to play and the changes paid dividends as the home side ran out of energy in the closing minutes and could not quite hold on for the win.