Andre Gray capitalised after Cardiff goalkeeper Simon Moore dropped Alex Pritchard's free kick to open the scoring in the first half.
But a mix-up between Brentford stopper David Button and defender Harlee Dean allowed the Bluebirds to level seven minutes into the second half.
And, with 22 minutes to go, a hopeful long ball beat the offside trap and, with Button in no-mans land, Alex Revell lobbed the goalkeeper to make it 2-1.
Kadeem Harris saw red for a foul on Alan Judge late on as Brentford poured forward looking for an equaliser before Federico Macheda also got his marching orders with two minutes remaining.
Brentford manager Mark Warburton said: “We made two mistakes and gave away two goals. Apart from that we dominated the game of football.
“It was a crazy game. I thought we were good for the 1-0. We got the goal and their intention to kill the tempo was clear from the start.”