Rotherham United earned their first win in four attempts under new manager Neil Warnock to move to within three points of Championship safety.
The Millers also scored for the first time under Warnock through Matt Derbyshire after good work by Lee Frecklington.
Brentford levelled when Alan Judge scored on the follow-up after his penalty was saved by Lee Camp.
But Rotherham secured a first win in eight games through Danny Ward.
Ward’s 71st-minute goal following a corner means the Millers, who occupy the final relegation place, are now within one victory of MK Dons, who lost a thrilling game against Blackburn Rovers.
The Bees had the better of things early on with home ‘keeper Camp making a superb save to deny Judge.
But Warnock’s men, playing in a predictably physical style, looked like they would be ahead at the break thanks to Derbyshire, only for referee Mark Brown to penalise Frecklington when he appeared to win the ball from Sergi Canos.
The Millers managed to block out the sense of injustice following the penalty equaliser, and Greg Halford went close and Ward saw a shot tipped on to the bar before Ward’s close-range winner.
Rotherham boss Neil Warnock:
“It’s nice to get the win, I said to the lads ‘how does it feel, that’s what you have to go through’.
“I really enjoyed it. They gave me absolutely everything, that’s the Championship, you have to do that as a minimum.
“We have got some tough games coming up but they will be tough for them. It helps to get three points, just to get us back in the mix. They couldn’t have given any more, we might be a bit limited, but we’re not lacking in the heart stakes.
“I love the Championship because it is the way it is. I am usually going for promotion and you always come unstuck against teams at the bottom. I think we can be a coupon-buster in the next few weeks.”
Brentford manager Dean Smith:
“What went wrong was we got involved in a tear up and that is not our game. Our game is about playing football, passing and moving it.
“We did it at times in the first half without really creating too many opportunities. In the second half, we have given opportunity for the official to give too many free-kicks.
“I thought we had a very harsh penalty given in our favour. I thought their lad has touched the ball, at the time I thought it was a penalty but I have seen it back. I want to know why the second half was managed and officiating in a different way to the first half.
“It got their tails up, then we got involved in a bit of a scrap and then it became a bit of a 50/50. We probably deserved to lose in the end. Both goals were very poor goals, but then we had a great chance to equalise afterwards.”