Deji Oshilaja was Mansfield's hero with a 90th-minute goal that earned them their first win in 15 games as they completed a League One double over Barnsley.
The late winner meant the Stags avoided equalling their all-time worst winless run of 14 league matches.
Mansfield keeper Christy Pym made an important double save on five minutes, denying Stephen Humphreys one-on-one and then keeping out Josh Benson's follow-up.
Oshilaja should have netted for the Stags on nine minutes but stabbed over from nine yards from Baily Cargill's cross from the left.
But they were ahead two minutes later as Will Evans' cross-field ball was superbly controlled by Stephen McLaughlin, who drilled it in low and Caylan Vickers poked in off the post for his first Mansfield goal.
Barnsley keeper Jackson Smith was hurt in the melee and had to be replaced by Keiren Flavell.
However, the Tykes were level on 54 minutes as Max Watters and Davis Keillor-Dunn worked the ball to Benson in space on the right and he beat Pym at his near post with a powerful 12-yard finish.
But a second half of few chances ended in high drama as Lucas Akins turned a deep McLaughlin cross inside where Oshilaja buried the winner from seven yards.
Match report supplied by PA Media.