Substitute striker Hector Sam's late goal fired Wrexham into the second round of the LDV Vans Trophy.
Sam turned the game after replacing Dean Bennett
The visitors drew first blood when Shaun Pejic squeezed the ball home from close range after 20 minutes.
Youssef Sofiane beat the offside trap and slotted in the equaliser, before a neat piece of control and finishing from Glynn Hurst put the Magpies ahead.
Sam fed Chris Llewellyn to level the game, then lashed home Matt Crowell's low cross for the winner.
Notts County: Henderson, Wilson, Friars, Baudet (Scully 81),
Whitlow, Pipe, Gill, Pead, Sofiane (Gordon 90), Hurst, O'Grady.
Subs Not Used: Deeney, McFaul, McIntyre.
Goals: Sofiane 24, Hurst 71.
Wrexham: Mathew Baker, Roberts, Morgan, Pejic, Whitley, Smith,
Jones (Crowell 73), Williams, Holt, Llewellyn, Bennett (Sam 45).
Subs Not Used: Spender, Mackin, Daniel Evans.
Goals: Pejic 20, Llewellyn 79, Sam 87.
Ref: K Friend (Leicestershire).