An own goal from Adam Matthews and a terrific strike from Jason Scotland gave Town the points as Blues moved into second place in the table.
Connor Wickham seemed to be denied a certain penalty when he went down under Gabor Gyepes' challenge 10 yards out in the first-half but Blues edged ahead on the hour, Carlos Edwards' cross headed into his own net by Matthews.
Former Swansea striker Scotland doubled the advantage 17 minutes from time, smashing a right foot strike past David Marshall to seal the points and take Blues above Cardiff in the table.
Roy Keane made three changes to the team that went down to QPR in midweek, Wickham was handed his first start of the season with Darren O'Dea and Tom Eastman also coming into the side.
Cardiff started the better and had a flurry of corners in the first five minutes, Marton Fulop clawing one in-swinger from Peter Whittingham away from the line.
Jay Bothroyd hooked over following a free-kick before Town began to get a foothold in the game and on 13 minutes - in Blues' first opening - Wickham got on the end of Andros Townsend's pass and burst into the Cardiff box before Gyepes' challenge brought him to the ground.
The Town bench were incensed as referee Fred Graham turned away the penalty appeals, pointing to a goal-kick instead.
Edwards dragged his shot wide then Townsend, who was bright throughout the first-half, poked an effort a yard wide after David Marshall hesitated from a Grant Leadbitter free-kick.
Marshall gathered easily from Wickham's header following an Edwards throw, then Townsend sent a free-kick just over.
Stephen McPhail was booked for a foul on Scotland, Wickham soon following into referee Graham's notebook after catching Lee Naylor.
Townsend and Wickham linked up - not for the first time - the Tottenham loanee feeding the teenager down the left channel, Wickham's shot deflected wide by Gyepes as the half came to a close.
Cardiff made two changes at the break, Gavin Rae and Matthews on for McPhail and Kevin McNaughton but it was Town who started on the front foot, Wickham denied by Gyepes' desperate challenge after Townsend's cross had only been partly cleared.
Jaime Peters replaced Townsend in Blues' first change 10 minutes into the second-half, and Town were inches away from taking the lead seconds later. Wickham showed strength and touch to get away from both Mark Hudson and Gyepes before seeing his shot deflect off Marshall and bounce over the bar.
The breakthrough came on the hour and in unexpected circumstances, Edwards' cross seemed to provide little threat but Matthews, who had diverted a similar cross back to Marshall five minutes earlier, this time planted his header into the corner of the net.
Blues extended the lead on 73 minutes, Eastman arrowed in a ball over the top of the Cardiff defence, Scotland took it down superbly and thumped a terrific strike past Marshall.
Cardiff looked for a response and Whittingham's header was tipped over by Fulop.
Scotland received a warm ovation as he made way for Colin Healy for the last 12 minutes, Peters then going close to a third for Town with a header from Leadbitter's free-kick.
The ovation was even louder when Wickham made his way to the sidelines, Tamas Priskin his replacement as Town freshened up the frontline.
Healy went close to adding a third late on after good work by Edwards, while at the other end Chris Burke fired over with the last kick before referee Graham's final blast on the whistle left Town the closest challengers to leaders QPR at the top of the table.
Town: Fulop, Eastman, McAuley, Smith, O'Dea, Edwards, Norris, Leadbitter, Townsend (Peters 55), Wickham (Priskin 82), Scotland (Healy 78). Subs not used: Murphy, Kennedy, Murray, Hyam. Booked: Wickham
Cardiff: Marshall, McNaughton (Matthews 46), Hudson, Gyepes, Naylor, Burke, McPhail (Rae 46), Blake, Whittingham, Keogh, Bothroyd. Subs not used: Heaton, Quinn, Koumas, Wildig, Jarvis. Booked: McPhail.
Att: 22, 599