A four-goal second-half blitz moved Wrexham into the play-off positions.
Jon Walters was at the heart of Wrexham's comeback
Mansfield were one up at the break, Richard Barker converting a penalty after he was fouled by Danny Williams.
Williams levelled with a strong header from Matt Crowell's corner, then Lee McEvilly combined superbly with Jon Walters to score a great left-footer.
Walters latched onto a Darren Ferguson ball to make it 3-1, and the striker fed Mark Jones who rounded things off with a cheeky chip over Kevin Pressman.
Wrexham: Ingham, Bayliss, Danny Williams, Lawrence, Roche, Crowell, Ferguson, Mark Jones (Warhurst 88), Smith, McEvilly (Bennett 84), Walters.
Subs Not Used: Michael Jones, Spender, Mike Williams.
Booked: Smith, Warhurst.
Goals: Danny Williams 49, McEvilly 53, Walters 61, Mark Jones 87.
Mansfield: Pressman, Peers (Russell 75), Day, Baptiste, Jelleyman, Birchall (Brown 63), Dawson (Buxton 56), Coke, Uhlenbeek, D'Laryea, Barker.
Subs Not Used: White, Rundle.
Goals: Barker 41 pen.
Ref: A Hall (W Midlands).