Glynn Hurst snatched a point for Bury with an injury-time equaliser and their first goal in six games.
What started nervously as a tussle between two sides scared of losing against fellow strugglers ended in excitement, with Wrexham down to nine men and fighting for their lives.
Early play was concentrated in midfield until Hurst made the first real effort on goal by hitting a hopeful 30-yard drive that brought a fine save by John Ruddy.
Hurst followed with an overhead shot that Ruddy missed and Gareth Evans cleared off the line.
Ryan Valentine next cleared for Wrexham after Hurst put Andy Bishop through as Bury launched another raid.
Lee McEvilly gave Wrexham the breakthrough with a well-taken goal by finishing from close in after good work by Chris Llewellyn and Mark Jones.
Bury had the next chances as Bishop put Hurst in at the back post and Shaun Pejic cleared.
Hurst was out of luck again a minute later when he shot wide from close range.
Wrexham missed a chance when Neil Roberts set up McEvilly who shot wide of an unguarded net.
Again, when Wrexham set up a raid, Jones put McEvilly through and Dave Challinor denied the Wrexham striker with a timely tackle.
Bury were keen to get on terms and should have levelled early in the second half when Bishop shot over from ten yards.
A two-footed tackle by Llewellyn on Jason Kennedy earned the Wrexham winger a straight red card and nine minutes later they lost another player when Valentine was sent off for a foul on Darren Kempson.
Having lost two players in quick succession, Wrexham sacrificed playmaker Jones and sent on Mike Williams in a bid to protect their slender lead.
The game swung completely in Bury's favour in the last half hour with Wrexham fighting a desperate rearguard action that nearly succeeded.
Ruddy had had to make several saves, but Robert Garrett could have made a big difference when he set off on a solo run from the halfway line and nearly scored.
But it was no more than the Shakers deserved when Hurst grabbed his goal deep into added time.