New signing Nathan Elder was an instant Brentford hit, grabbing an 85th-minute winner to settle a thrilling match and send the Stags to the bottom of the table – and their fourth successive home League defeat.
With the home side appealing for offside, Elder - a midweek £30,000 capture from Brighton - raced clear to tuck in the winner under stranded keeper Carl Muggleton.
The Stags thought they had earned a precious point when new signing Jefferson Louis scored from close range in the 64th minute, just seven minutes after coming on.
But then came Elder's late winner, making amends for his early own goal, to stretch Brentford's unbeaten run to six matches and boost their play-off hopes.
The Stags, chasing consecutive victories for the first time this season, should have taken a fifth-minute lead from their first corner.
A well-worked routine saw Stephen Dawson's deep cross find Jake Buxton. His firm header struck the bar and, from the rebound, John Mullins' header was cleared off the line by Craig Pead.
A minute later fine link-up play between Ian Holmes and Micky Boulding put the 17-goal striker clear, but he pulled his final shot well wide.
Matt Hamshaw curled a free-kick straight into keeper Ben Hamer's arms and then Boulding's close-range poke was blocked by Charlton loanee Osei Sankofa.
It was all Mansfield in the opening stages and they got the goal they deserved in the 15th minute.
Boulding rose highest to head on Hamshaw's long free-kick and the ball deflected in off the outstretched leg of Elder.
A minute later Brentford finally posed an attacking threat, but Alan Connell's fierce header from Ryan Dickson's free-kick flashed inches wide.
The Bees, galvanised by the goal, were suddenly dominating. Connell's flick gave Glenn Poole the chance to unleash a terrific deflected 25-yard drive which keeper Muggleton finger-tipped away - Gareth Jelleyman completing the clearance by heading the ball away for a corner.
From that flag kick Elder almost made amends for his own goal, but Muggleton again came to the Stags' rescue with another fingertip stop.
However, he could do nothing about a fantastic Kevin O'Connor 20-yard free-kick which flew into the top corner in the 26th minute.
As chances came thick and fast at both ends, Holmes and Boulding had shots charged down inside the area for Mansfield and Dawson poked narrowly wide, while Poole's low drive was just saved by the diving Muggleton and Jelleyman scrambled the loose ball away from Ricky Shakes as Brentford threatened to grab the lead on half-time.
Just 30 seconds after the break, more good work by the impressive Connell set up Gary Smith for a first-time drive which beat keeper Muggleton and the post.
With Brentford looking dangerous at every attack and the Stags labouring in midfield another goal looked inevitable and in the 56th minute Smith's neat pass gave Connell the chance to turn and fire across Muggleton and into the bottom corner.
The goal prompted a double substitution from Mansfield boss Billy Dearden and, within seven minutes of making his debut Louis, had slid in an equaliser after Boulding battled through four challenges.
Yet another fine save by Muggleton, beating away a fierce Shakes shot, kept the home side level.
Mansfield thought they had won it when Hamshaw's curling free-kick eluded everyone, but just grazed the outside of the post. Then Louis' shot was deflected narrowly wide.
And those near misses proved vital when Brentford grabbed their 85th-minute winner.