The Bluebirds fell behind after only five minutes when Neal Maupay gave Dean Smith's playoff hopefuls a perfect start to the match, but a stunning strike from Sol Bamba levelled the scores before Callum Paterson gave Cardiff the lead on the stroke of half time.
Kenneth Zohore added a third for the visitors 10 minutes into the second half, and that proved to be enough to wrap up a seventh consecutive Championship win, leaving Neil Warnock's side seven points clear of third-placed Aston Villa, who were beaten at home by Queens Park Rangers this evening.
Brentford, meanwhile, have now lost back-to-back matches to find themselves eight points off the playoff places with only nine games of the season remaining.
It took just 20 seconds for the hosts to create the first clear chance of the game when a sweeping team move ended with Maupay being teed up inside the area, but his low drive was kept out by the feet of Neil Etheridge in the Cardiff goal.
The visitors soon responded, though, and almost took the lead in unorthodox fashion when Junior Hoilett's inswinging corner caught everyone out and skimmed the top of the crossbar on its way behind.
An early goal looked likely, and sure enough it arrived after only five minutes when Maupay - who was guilty of one of the misses of the season in the return fixture - put those demons to bed by beating the offside trap and slotting past Etheridge when one on one.
It was the first time that Cardiff had fallen behind in the league since New Year's Day, but they almost produced a quick response as the end-to-end nature of the opening exchanges continued, only for Paterson to fire straight at Daniel Bentley after good work from Zohore down the left flank.
The frantic start to the game did soon settle down, but Brentford were still pushing for a second and both Ollie Watkins and Chris Mepham failed to make the most of presentable chances from the edge of the area midway through the half.
Instead it was Cardiff who got the game's second goal moments later as Bentley's smart save down low to his right from Hoilett's effort proved to only be a temporary reprieve. The resulting corner was not properly dealt with by the Brentford defence and the ball eventually fell to Bamba, who produced a brilliant volley on the turn which flew into the top corner.
The hosts responded well to that equaliser, though, and a one-two between Sergi Canos and Maupay almost saw them regain their lead shortly afterwards, only for Etheridge to thwart the Spaniard.
Maupay then fired a long-range effort over the crossbar, but Cardiff also continued to look dangerous and it took a brave stop from Bentley to deny Nathaniel Mendez-Laing when the winger was sent clean through on goal with nine minutes remaining of the first half.
A stinging drive from Canos in the final minute of the first half then needed to be saved by Etheridge, but it was the visitors who had the final say of an action-packed opening 45 minutes when Paterson converted Hoilett's cross in stoppage time to send Cardiff into the break with the lead.
Warnock's side had won all 13 of their Championship games this season in which they had been leading at half time, and the news that their closest automatic promotion rivals Aston Villa were losing 2-0 at the halfway stage of their home match against QPR will only have buoyed the Bluebirds further.
Brentford almost brought them back down to earth 10 minutes after the restart when Watkins was played in down the right channel, but Bamba made a fine last-ditch block which sent the ball looping over the crossbar and onto the roof of the net.
Cardiff soon took complete control of the contest with their third goal moments later, though, as Brentford again failed to deal with an aerial ball into the box, allowing Zohore to poke home from a knockdown shortly before the hour mark.
The visitors were not content with just a two-goal lead and continued to push for more, with Bentley forced to claw away another Zohore effort before the Cardiff striker saw a firm downward header cleared off the line.
Zohore continued to prove a nuisance for the home side and found himself through on goal with just over 15 minutes remaining, but he could not squeeze his header past Bentley having beaten the Brentford keeper to the bouncing ball.
The hosts did almost find a route back into the match when John Egan darted to the near post and flicked a header towards goal which drew a smart save from Etheridge, and the Brentford skipper then squandered an even better chance with less than 10 minutes remaining.
Again it came from a set piece as the ball bounced kindly for Egan inside the penalty area, but the centre-back could only fire his half-volley wide of the target from close range.
Brentford continued to push for a goal which would have set up a grandstand finale, but substitute Alan Judge wasted another good chance when he got the better of Bruno Ecuele Manga but then opted to go for goal from a tight angle when he had teammates better positioned in the area.
The best chances continued to fall for Egan, though, and the defender was again the wrong person in the right place when he sliced a stoppage-time effort well off target with the goal gaping.
That was the final chance for the Bees as they slumped to defeat, while Cardiff were left celebrating a victory which keeps them within three points of leaders Wolverhampton Wanderers, who returned to winning ways against Reading this evening.
BRENTFORD (4-2-3-1): Bentley; Clarke, Egan, Mepham, Barbet; Yennaris (MacLeod, 69'), Woods, Canos (Marcondes, 69'), Sawyers, Watkins; Maupay (Judge, 76')
CARDIFF (4-2-3-1): Etheridge; Ecuele Manga, Morrison, Bamba, Bennett; Grujic, Damour, Mendez-Laing (Traore, 88'), Paterson, Hoilett (Wildschut, 82'); Zohore (Madine, 77')