A tremendous goal-line clearance by Alex Baptiste three minutes into injury time denied Liam Rosenior a late Torquay equaliser in a titanic promotion clash and ended the Gulls' 13-match unbeaten run.
The defender raced back to clear after Rosenior's faint flick had beaten keeper Kevin Pilkington on Torquay's last attack of a pulsating match.
The Stags, who held on for their first win in five matches, should have made the game safe 11 minutes from time when sub Andy White crossed to the unmarked Junior Mendes, but with the goal at his mercy the striker was denied by Kevin Dearden's flying save.
The home side had got off to the perfect start when the recalled Colin Larkin grabbed his first goal since Boxing Day.
Torquay failed to clear a fourth minute corner and the tricky Wayne Corden crossed back into the penalty area, the ball fell kindly to Neil Mackenzie 25 yards out and his fierce drive was diverted in by Larkin.
With Mansfield totally dominating the play they added a second just six minutes later.
Full-back Craig Taylor misjudged Reuben Hazell's long throughball and Mendes nipped in to lob the keeper for his first goal in 19 games.
However within six minutes the Gulls were back in the game from their first attack. This time Mansfield failed to clear a set-piece and although the diving Pilkington blocked David Graham's low drive, Martin Gritton knocked in the rebound.
Two minutes later the dangerous Graham almost levelled, but this time the keeper managed to hold his fierce drive.
In a thrilling opening half-hour Mendes then turned neatly and struck the post in a goalmouth scramble.
But six minutes into the second half the woodwork then saved the Stags. Gritton broke clear of the offside trap and when his sidefooted shot struck the foot of the post, sub Jo Kuffour fired the rebound into the sidenetting.