Aiden Flint's first goal of the season ensured Cardiff secured a 1-0 win over Swansea at the Liberty Stadium and a first victory in the South Wales derby since 2013.
Swansea headed into the game unbeaten in their previous four league games against Cardiff, but they fell behind inside eight minutes when Flint reacted quickest to Freddie Woodman's save from Marlon Pack's initial effort to head the ball into the roof of the net.
Steve Cooper's side dominated the second period, but came closest to levelling when Connor Roberts' corner was flicked onto the post by Andre Ayew.
But Cardiff held on to deny Swansea a league double over their rivals and with it move up to eighth in the Sky Bet Championship table, four points outside the plays. Swansea remain in third place, six adrift of Watford in second with a game in hand.
Swansea handed a first start to 20-year-old Morgan Whittaker in attack with Jamal Lowe - their two-goal hero in the reverse fixture - on the bench. Cardiff, meanwhile, were without in-form right-back Perry Ng.
Swansea's Conor Hourihane was fouled by Will Vaulks on the edge of the box early on. Hourihane stepped up and curled a free-kick towards goal which Dillon Phillips tipped wide for a corner. Cardiff responded by taking the lead from a trademark set-piece.
Vaulks launched in a long throw and it fell to Marlon Pack, whose poked effort on goal was brilliantly saved by Swansea goalkeeper Woodman but Flint reacted quickest to power home a header.
Swansea's eagerness to play out from the back was being tested by Cardiff's impressive pressing and Leandro Bacuna forced Woodman into action again from an away counter-attack.
Swansea's strife was not improved by them losing key man Hourihane, who had initially tried to run off a thigh muscle injury. Korey Smith was the man to come on. Cardiff captain Sean Morrison also headed a monster Vaulks free-kick wide, while Swansea's Jay Fulton and Matt Grimes put speculative efforts over the bar.
Just before the break, a Woodman error played in Cardiff striker Kieffer Moore, who ran in on goal but could not convert. Ryan Bennett got back to clear the danger.
The pace of Swansea's game improved at the start of the second period and Whittaker had a shot saved. Ayew was then fouled on the edge of the box by Vaulks to earn a home free-kick.
Ayew curled the resulting effort wide, with Phillips unbothered. Whittaker also blazed over when he should have at least hit the target, while at the other end Woodman denied Harry Wilson on another counter. Wilson had been quiet to that point.
Ayew came within inches of levelling the scores when his header from a Connor Roberts corner beat Phillips but not the post. Swansea introduced Lowe and Ryan Manning and switched to a back four in search of an equaliser, but although they dominated the ball, they could not break through.
Cardiff City: Phillips, Sang, Morrison (C), Flint, Brown, Ralls, Pack, Vaulks, Bacuna (Murphy 66), Wilson (Ojo 84), Moore.
Subs not used: Smithies, Bowen, Williams, Colwill, Hoilett, Harris, Watters.
Swansea City: Woodman, Roberts (Lowe 76), Naughton, Bennett, Guess, Bidwell (Manning 76), Fulton (Dhanda 80), Grimes (C), Hourihane (Smith 18), Ayew, Whittaker.
Subs not used: Hamer, Latibeaudiere, Cabango, Routledge, Cooper.