WREXHAM were staring defeat in the face last night until two late goals in the space of seven minutes turned the tables on League Two side Notts County at Meadow Lane.
The Dragons looked like crashing out of the LDV Vans Trophy to their lowly opponents at the first hurdle until an equaliser from Chris Llewellyn and a late winner from substitute Hector Sam saw them through to the second round.
Denis Smith's side could count themselves slightly fortunate to record a first win in three matches after twice conceding dreadful goals.
And they needed a huge slice of good fortune to haul themselves back into the contest with just 11 minutes remaining.
In something of a surprise, Dragons' boss Denis Smith relegated Sam to the bench and pushed Dean Bennett up front alongside Llewellyn in a side showing three changes from Saturday's line-up.
Craig Morgan deputised for the rested Brian Carey at the heart of defence and Mark Jones was given his first start of the season in place of the injured Darren Ferguson.
Meanwhile Jim Whitley, who was captain for the night in the absence of Ferguson, came in at wing-back in only his second start in seven games.
There wasn't much to choose between the two sides in the opening skirmishes as Yousseff Sofiane's 20-yarder, which curled wide, was matched by a defencesplitting pass from Andy Holt, which was just too long for Jones.
And Wrexham probably deserved on the balance of play to go ahead after 20 minutes.
David Pipe, clearing off the line from Danny Williams' header, conceded a corner and when the ball was delivered, Steve Roberts headed it back for Shaun Pejic to score with a volley.
Three minutes later Llewellyn was denied by goalkeeper Wayne Henderson's superb save following a sweeping Wrexham move, but all the visitors' hard work was undone by some sloppy defending after 24 minutes.
Another Dragons corner was cleared and Craig Pead's long ball forward saw Sofiane outpace lone defender Alex Smith to beat Matt Baker, who might have come out earlier than he did.
County's confidence soared and the goalscorer saw another fierce shot deflected for a corner.
Julien Baudet had an effort disallowed for offside and Baker saved with his legs from Chris O'Grady, so it was Wrexham who were relieved to hear the half-time whistle.
Sam came on for Bennett from the restart but it was Jones who went close to restoring the lead after 55 minutes. He hit a shot from 20 yards to bring a save from Henderson, who made it look easier than it was.
Otherwise the home side looked comfortable at the back as Sam and Llewellyn were forced to feed on scraps.
At the other end Baudet was not far away with a header - injuring himself in the process - from Sofiane's corner.
And County snatched the lead with 19 minutes remaining in similar fashion to their equaliser.
Pipe drilled a long ball forward from inside his own half and Glynn Hurst brought it down superbly before clipping it past the stranded Baker.
The goal prompted Wrexham's second change, the disappointing Jones making way for Matt Crowell.
But there was little evidence that the visitors would force their way back into contention until they enjoyed an outrageous piece of luck after 79 minutes.
Holt fed Sam, who twisted in the penalty area to lay the ball on a plate for Llewellyn six yards from goal.
The striker's close-range shot hit Emmet Friars on the line but the rebound struck the Wrexham man on the head and looped back into the net.
And remarkably the visitors' slickest move of the match brought the winner on 87 minutes.
Pejic went forward, brought Llewellyn into play and Sam was on hand to play and receive the one-two before slotting the ball past Henderson, saving the Dragons' blushes..
But it needed a smart last-minute save by Baker from substitute Gavin Gordon to ensure Wrexham a place in round two as the determined home side pushed to keep themselves in the competition.
* MAN OF THE MATCH: Steve Roberts, as he did on Saturday, marshalled the defence superbly.
NOTTS COUNTY: Henderson; Wilson (Gordon 89), Friars, Baudet (Sully 81), Whitlow; Pead, Gill, Pipe, Sofiane; O'Grady, Hurst. Subs: Deeney, McFaul, McIntyre.
WREXHAM: Baker; Pejic, Morgan, Roberts; Whitley, Jones (Crowell, 72), Williams, Smith, Holt; Bennett (Sam 46), Llewellyn. Subs: Spender, Mackin, Evans.
REFEREE: Kevin Friend ATT: 1,359