Non-league Harrogate Railway came close but could not cause an upset as Mansfield Town nervously booked their place in the FA Cup third round.
Substitute Danny Davidson scored two goals for non-league Harrogate
In muddy conditions at Station View, Harrogate set the early pace with Scott Ryan curling a free kick onto the bar.
Mansfield made their class tell with a 38th minute Gareth Jelleyman goal and two from Michael Boulding.
But substitute Danny Davidson scored two second-half goals to put Harrogate within reach of a heroic comeback.
Harrogate, the joint-lowest ranked team left in the competition, were always chasing the game against a team 81 places above them in the league pyramid structure.
Through the forward partnership of brothers Michael and Ryan Boulding, Mansfield had much of the play.
Yet, between Boulding's two second-half goals, Harrogate's Davidson came off the bench to head in off the bar with his first touch and finish coolly for a second goal to set up a frenetic finish with the score at 3-2.
And in the last minute Davidson, who works for a building society, shot powerfully at goal from the edge of the area.
But Mansfield keeper Karl Muggleton stopped it to keep his team on course for a third round meeting with Brighton & Hove Albion.
Harrogate Railway: Mclaughlin, Haigh, Robert Morgan, Riley (Blair 70), Lowe, Littlefair, Adam Jones (Conway 60), Scott Ryan, Matt Morgan, Marshall, Smith (Davidson 60).
Subs Not Used: Turner, Thirkall.
Goals: Davidson 61, 84.
Mansfield: Muggleton, Mullins, Baptiste, Buxton, Martin, Hamshaw, Bell, Dawson (D'Laryea 88), Jelleyman, Michael Boulding, Rory Boulding (Brown 74).
Subs Not Used: White, Martin McIntosh, McAliskey.
Goals: Jelleyman 38, Michael Boulding 51, 77.
Ref: Mike Pike (Cumbria).