Nathan Jarman ended Wrexham's hopes of reaching the FA Cup first round with his second-half goal.
Boos rang out at the Racecourse at the final whistle as the team lying 24 places below Gary Mills' National League side celebrated.
Striker Jarman's 73rd-minute free-kick broke the deadlock in the fourth qualifying round.
Gainsborough go into the first round draw for first round games that take place on the weekend of 7 November.
Wrexham boss Gary Mills told BBC Radio Wales: "We created chance after chance and that's as simple as it is today.
"I think they've had one shot - and probably one in the first half - but one shot in the back of my net and we've missed chance after chance.
"And not half chances. We talking unbelievable chances to go and win a football match and we haven't taken them."