Wrexham secured their third consecutive home win in League One courtesy of Ollie Rathbone's injury-time winner.
Ryan Barnett forced Barnsley keeper Ben Killip into a save after nine minutes when his left footed shot was parried. Wrexham were forced to make a change midway through the first half when goalkeeper Callum Burton was forced off with an injury and replaced by Mark Howard.
Wrexham came close to taking the lead after 39 minutes when Matty James' half volley was well saved by Killip.
The second half was similar to the first half with neither side dominating. Max Cleworth who has scored five goals this season nearly added another to his tally and Killip in the Barnsley goal was again in the action to deny Elliot Lee's fine shot from the edge of the penalty area.
Paul Mullin and Steven Fletcher came off the bench with over 20 minutes remaining for Lee and Ollie Palmer, but it Barnsley substitute Fabio Jalo nearly gave the visitor's the lead, but his shot was saved by Howard.
Fletcher came close in the dying minutes and with a draw looking most likely Rathbone's left footed strike was enough to clinch the three points for the hosts, who stay second while Barnsley are eighth.
Wrexham manager Phil Parkinson:
"Barnsley came here with a good away record and you can see why, they are a resilient team and they don’t take too many risks.
"They are powerful at set-plays and I thought we the way we defended set-plays and dealt with that style was outstanding.
"We said before the game and reiterated at half-time that it would be a moment to separate the teams and could we produce it? We did with an unbelievable goal, a great bit of football.
"Ollie Rathbone capped off an outstanding performance from him with a brilliant goal."