Sheffield Wednesday hotshot Shefki Kuqi lost his touch as Wrexham came from behind to sink the promotion favourites.
The Finland international who has hit the net four times this season squandered two good chances and had a goal disallowed as the Hillsborough side lost ground on the leaders.
Wednesday swept ahead in the second minute, Paul McLaren picking out midfielder Alan Quinn, who finished with a crisp left-foot shot from the edge of the area.
Kuqi should have grabbed a second on 14 minutes as he ran on to a Derek Geary cross but he headed wide from six yards.
Kuqi had a shot blocked after neat work by Geary again and when he finally found the target the goal was ruled out.
Wednesday were made to pay for their missed chances when Wrexham pulled level five minutes before the interval, lanky centre-back Dennis Lawrence connecting with a Darren Ferguson corner to head home from six yards.
Keeper Ola Tidman saved Wednesday seconds later diving to his left to keep out a Stephen Thomas shot.
Wrexham snatched the lead with a spectacular strike on 53 minutes, Chris Llewelyn hitting the target with a left-foot effort from 22 yards, the ball curling into the top right-hand corner.
Carlos Edwards added Wrexham's third in the 64th minute, tucking inside from the right flank after Brian Barry-Murphy slipped before tucking his angled drive into the far corner.
Substitute Paul Smith gave Wednesday hope 12 minutes from time, his shot crashing against the post and hitting defender Brian Carey before crossing the line.
Wednesday, playing four strikers, piled on the pressure in the dying minutes as Wrexham clung on.
Winger Terry Cooke caused havoc on the right flank as Wrexham piled men into the box.
Striker Grant Holt went close along with Quinn as Wrexham clung on to their undefeated record to keep them among the promotion pack.