Nathan Elder hit the winner on his Brentford debut, after giving Mansfield the lead with an own goal, as the Bees moved into the top half of the table.
Jake Buxton had already hit Brentford's bar before Elder diverted Michael Boulding's header into his own net.
Kevin O'Connor equalised with a superb 25-yard free-kick before Gary Smith set up Alan Connell to put Brentford ahead.
Mansfield's debutant Jefferson Louis levelled from Boulding's pass before Elder broke free to hit the winner.
Mansfield: Muggleton, Jelleyman, Buxton, Mullins, Wood, Bell, D'Laryea (Atkinson 57), Dawson, Hamshaw, Holmes (Louis 57), Michael Boulding.
Subs Not Used: White, Brown, Arnold.
Goals: Elder 15 og, Louis 64.
Brentford: Hamer, Dickson, Heywood, Sankofa, Pead, Poole (Parkes 77), O'Connor (Stone 79), Smith, Shakes (Montague 90), Elder, Connell.
Subs Not Used: Simon Brown, Osborne.
Goals: O'Connor 25, Connell 56, Elder 85.
Ref: Jon Moss (W Yorkshire).