Mansfield Town spoiled Andy Morrell's first home game as Wrexham interim manager as the Stags reignited their Blue Square Bet Premier play-off push.
A Danny Wright own goal gave Mansfield the lead as he headed Luke O'Neill's ball past his own keeper.
Wrexham's Lee Fowler levelled with a long-range strike before Matthew Green's penalty put Mansfield ahead.
Nathaniel Knight-Percival, who fouled Ross Dyer for the penalty, was sent off before Paul Connor's third for Town.
Mansfield substitute Connor's injury-time close-range strike into the corner of Chris Maxwell's net, from Dyer's incisive through ball, knocked Wrexham off the top of the table.
But Mansfield also finished the game with 10 men as Tom Naylor was red-carded for a challenge on Adrian Cieslewicz.
VIEW FROM THE DRESSING ROOM
Wrexham interim manager Andy Morrell:
"That was hard to take. There was a really good atmosphere here and really good game for us and I'm just really disappointed.
"The last goal, it doesn't matter about that as we were going for it. But I was just so proud of the players in the last 25 minutes of the game as it was 10 men against 11 and it seemed to take the sending off to spark us into life.
"The reaction from the lads I can't fault and I'll take that as the positive out of the game."