Substitute Liam Dickinson scored a last-gasp winner as Stockport denied a spirited Wrexham side.
The striker headed over Wrexham goalkeeper Michael Ingham in the 93rd minute following a disputed free-kick.
The home side had enjoyed the better of the play in the first half with Paul Mitchell and Danny Williams going close with headers from corners.
Mitchell then spurned a chance from 10 yards out and the home side were made to pay by Dickinson's late winner.
Wrexham: Ingham, Roche, Pejic, Danny Williams, Valentine, Llewellyn, Garrett, Mitchell, Done, McEvilly (Reed 78), Marc Williams (Samba 65).
Subs Not Used: Michael Jones, Mike Williams, Fleming.
Booked: Danny Williams.
Stockport: Hennessey, Clare, Williams, Owen, Rose (Pilkington 64), Poole, Taylor, Gleeson, Griffin, Elding (Dickinson 90), Proudlock (Bramble 64).
Subs Not Used: Spencer, Dinning.
Booked: Taylor.
Goals: Dickinson 90.
Att: 4,060
Ref: A Hall (W Midlands).