Gainsborough upset the odds to stun Wrexham and march on to the first round proper of the FA Cup for the first time since 2007.
Nathan Jarman’s 73rd minute free kick was enough for the Blues, as a combination of heroic defending and poor finishing from the Welsh side, meant Trinity gained revenge for their FA Trophy semi final defeat to the Dragons in 2013.
The Blues started the day at 8/1 to beat the National League side due to their struggling of late in the league.
They have saved their form for the cup this season and after defeating rivals Boston, they have since added a win over Droylsden.
Trinity lost to Brackley last time out and manager Steve Housham made two changes to the side which were defeated in Northamptonshire.
Out went Danny Forrest and Jamie Yates with Charlie Binns and Darryn Stamp starting in their place.
This meant the Blues lined up with three strikers on the pitch as they looked to go for it in Wales.
However, the three attackers never gone into the game in the first half as Trinity struggled to maintain possession of the football.
Wrexham dealt with the approach well and utilised the space down the flanks which had been exposed as the Blues aimed to go all guns blazing.
The home side forced Jan Budtz into a save within the opening few minutes.
Winger Dominic Vose broke down the left for the Dragons, whipped in a dangerous cross and Budtz managed to beat the oncoming Connor Jennings to the ball to relieve the danger.
It was the turn of Wesley York next for the North Wales side as he cut in from the right and hit a strike wide of the near post.
Striker Kayden Jackson then began to cause problems with his pace and trickery.
Jackson hit a cross-shot which Budtz had to claw away before volleying wide after a slick interchange on the edge of the 18 yard line.
Right back Javan Vidal got in on the act next as ball from deep in midfield sliced the Gainsborough back four in half and Vidal somehow poked wide despite being clean through.
The travelling Blues fans had to wait until the 34th minute for a shot at goal, with Simon Russell turning into space 25 yards out and curling a shot on target but they ended the half a lot brighter as they began to work the ball out wide and in doing so won a late corner.
The Blues used this momentum after the break to come close in the opening five minutes of the second period.
A long punt upfied from Jan Budtz found Darryn Stamp in the area and after much jostling in the area he managed to get a touch with his head that sent Cameron Belford in the Dragons goal scampering to his near post as it whizzed wide.
The chance panicked the home side and they upped the tempo as they had done in the opening 20 minutes.
It did not take long to get a look at goal and midfielder Robbie Evans must still wonder how he did not score.
York fired in a low cross to Evans and somehow missed the target from a couple of yards out.
It seemed to be the poignant moment in the game as the hosts grew frustrated.
Evans tried again to rectify the miss ten minutes later with a left foot curler from the edge of the box that came mightly close.
Trinity responded well and after Jamie Yates had fizzed a shot on target, the same man won a free kick.
The shot from Jarman was blocked but he was felled in the aftermath and had another chance from 20 yards.
This time he grabbed the opportunity with both hands, thumping a free kick into the back of the net via a deflection.
Cue wild celebrations on the pitch and in the stand, with Trinity needing to hold out for 17 minutes to secure a great upset.
The Wrexham players were stunned and it took them a while to recover.
They really lacked quality in the final third though and their desperation to get back into the game proved pivotal.
They put together a run of corners but to no avail and thanks to excellent defending the Blues looked to cruise to victory, thanks to key interceptions from Matt Wilson, Jake Picton and Dominic Roma.
In the second minute of injury time came the best chance for Wrexham when dangerman Vose drove into the box and forced Budtz into a superb save low down to his left hand side.
The Blues held on for an unlikely victory and will be hoping to make history in the first round proper.
Gainsborough Trinity: Budtz, Roma, Lacey, Binns, Wilson, Picton, Russell, D’Laryea, Newsham (Davis 84), Jarman (Forrest 79), Stamp (Yates 63). Subs (not used): Hedge, Brogan, Rigby.
Wrexham: Belford, Vidal, Newton, Smith, Fyfield, Vose, Jennings, Carington (Hudson 79), Jackson (Fowler 79), Evans, York (Gray 57). Subs (not used): White, Logan, Sharpe, Quigley.
Goals: Jarman 73.
Bookings: Binns; Vose, Fyfield.
Referee: Mr J. Johnson.
Assistants: Mr D. Underwood, Mr D Issawi.