Middlesbrough ended Cardiff's 11-match unbeaten run thanks to Faris Haroun's worthy winner at the City Stadium.
The Belgian midfielder ghosted between two defenders to fire through the legs of Cardiff goalkeeper David Marshall.
Bart Ogbeche had given Boro the lead with a deflected shot, but Ben Turner headed an equaliser from a corner.
Cardiff went ahead when Kenny Miller's backheel picked out Aron Gunnarsson, only for Scott McDonald to side-foot Boro level before Haroun struck.
The win, which sees Boro leapfrog their hosts into third in the Championship, echoed their three-goal victory in Cardiff last season that derailed the Bluebirds' play-off bid.
Signs that this would become a full-blooded encounter came early, when Middlesbrough striker Ogbeche threw himself at Haroun's teasing cross.
Cardiff centre-back Mark Hudson was no less committed, and the heads of the two players came together with a worrying thud. Thankfully, both were able to carry on after treatment.
Cardiff, in front of a season-high 23,373-strong crowd, were left exasperated when Kevin McNaughton nicked the ball past Jason Steele in the area and seemed to be clearly felled by the goalkeeper, only for referee Graham Salisbury to wave away the penalty appeals.
The home side's sense of injustice was compounded as Middlesbrough took the lead moments after.
Ogbeche cut inside from the left and unleashed a pile-driver that took a wicked deflection off Hudson and spun in past Marshall.
But Cardiff were soon level as Peter Whittingham's corner was flicked on by Miller at the near post, allowing centre-back Turner to head home his first goal for the Welsh club.
Then moments before half-time, Miller ran at the heart of the Boro defence, taking two defenders with him before backheeling into the path of Gunnarsson, who shot past Steele from close range.
But while Boro boast the best defence in the division, they showed their attacking prowess in the second half.
McDonald nodded wide of the left-hand post after 50 minutes, before McNaughton blocked Ogbeche's attempt. But Cardiff were only able to hold off their guests until the hour mark.
Full-back Justin Hoyte busted a gut to create the overlap down the right and found McDonald in space.
The in-form Australian striker had timed his run to the near post and pushed the ball under Marshall as the keeper came out.
With 14 minutes remaining, Haroun broke Cardiff hearts as Julio Arca played a ball into box for the midfielder as he ran between two defenders.
The Belgian expertly chested down the spinning ball before smashing in the winner from close range.
Whittingham did go close with a 25-yard free-kick as Cardiff searched desperately for a leveller, but despite a late goalmouth scramble the hosts could not find a way through.
Live Text Commentary
Full Time The match has reached full-time.90:00 +4:24
Andrew Taylor takes a shot. Blocked by Justin Hoyte. Corner taken by Joe Mason from the left by-line, Matthew Bates fouled by David Marshall, the ref awards a free kick. Direct free kick taken by Jason Steele.90:00 +0:09
Aron Gunnarsson takes a shot. Bart Ogbeche gets a block in. Corner taken by Joe Mason, Filip Kiss takes a shot. Blocked by Bart Ogbeche. Filip Kiss challenges Bart Ogbeche unfairly and gives away a free kick. Jason Steele restarts play with the free kick.88:19
Barry Robson concedes a free kick for a foul on Peter Whittingham. David Marshall takes the free kick.87:24
Justin Hoyte takes the direct free kick.87:24 Booking
Booking The referee books Andrew Taylor for unsporting behaviour.87:15
Unfair challenge on Scott McDonald by Andrew Taylor results in a free kick.86:04
David Marshall takes the direct free kick.86:04 Booking
Booking Barry Robson is given a yellow card.85:53
Andrew Taylor fouled by Barry Robson, the ref awards a free kick.85:22
Scott McDonald decides to take the corner short.83:09
Free kick awarded for a foul by Barry Robson on Kevin McNaughton. Free kick taken by Mark Hudson.81:38
Direct strike on goal from the free kick comes in from Peter Whittingham.81:38 Booking
Booking Faris Haroun booked for unsporting behaviour.81:30
Faris Haroun challenges Kenny Miller unfairly and gives away a free kick.80:18
Shot from just outside the area by Aron Gunnarsson misses to the left of the target.79:04
Julio Arca gives away a free kick for an unfair challenge on Filip Kiss. Free kick crossed left-footed by Peter Whittingham, Rudy Gestede makes a clearance.78:48
Justin Hoyte takes a shot. Save by David Marshall.77:16
Centre by Barry Robson, Bart Ogbeche takes a shot. David Marshall makes a save.77:16 Booking
Booking The referee cautions Ben Turner for unsporting behaviour.
Scott McDonald fouled by Ben Turner, the ref awards a free kick.75:02
Assist by Julio Arca.75:02 Goal scored
Goal! - Faris Haroun - Cardiff 2 - 3 Middlesbro A goal is scored by Faris Haroun from inside the six-yard box low into the middle of the goal. Cardiff 2-3 Middlesbrough.74:26
Aron Gunnarsson takes a shot. Rhys Williams gets a block in.72:31
Unfair challenge on Joe Mason by Faris Haroun results in a free kick. Mark Hudson takes the free kick.70:21
The referee blows for offside against Scott McDonald. Filip Kiss takes the free kick.69:58
Unfair challenge on Matthew Bates by Rudy Gestede results in a free kick. Direct free kick taken by Matthew Bates.69:22
Corner taken by Barry Robson from the right by-line, clearance made by Rudy Gestede.67:03
Ben Turner takes the free kick.67:03 Substitution
Substitution (Cardiff) makes a substitution, with Rudy Gestede coming on for Don Cowie.67:03 Substitution
Substitution (Cardiff) makes a substitution, with Joe Mason coming on for Craig Conway.67:03
Faris Haroun concedes a free kick for a foul on Peter Whittingham.65:34
Peter Whittingham takes a shot. Save made by Jason Steele. Kenny Miller has an effort at goal from just outside the box which goes wide of the right-hand post. Barry Robson produces a left-footed shot from just outside the box that misses to the right of the target.64:13
Free kick awarded for an unfair challenge on Mark Hudson by Matthew Bates. David Marshall takes the direct free kick.63:29
Barry Robson takes a inswinging corner from the right by-line played to the near post, David Marshall makes a save.62:37
Corner taken left-footed by Peter Whittingham from the right by-line to the near post, clearance by Joe Bennett.61:10
Scott McDonald takes a shot. Save by David Marshall.59:57
The assist for the goal came from Justin Hoyte.59:57 Goal scored
Goal! - Scott McDonald - Cardiff 2 - 2 Middlesbro Scott McDonald finds the back of the net with a goal from close range to the bottom left corner of the goal. Cardiff 2-2 Middlesbrough.57:56
Peter Whittingham takes a corner.56:51
The referee blows for offside. David Marshall takes the free kick.53:41
Bart Ogbeche takes a shot. Kevin McNaughton gets a block in. Corner taken left-footed by Barry Robson, Kenny Miller manages to make a clearance.51:55
Free kick crossed by Don Cowie, Kenny Miller gives away a free kick for an unfair challenge on Jason Steele. Jason Steele restarts play with the free kick.51:55 Booking
Booking Justin Hoyte receives a yellow card for unsporting behaviour.51:43
Craig Conway fouled by Justin Hoyte, the ref awards a free kick.49:48
Andrew Taylor challenges Faris Haroun unfairly and gives away a free kick. A cross is delivered by Barry Robson, Headed effort from inside the area by Scott McDonald misses to the left of the goal.49:27
The referee gives a free kick against Kevin McNaughton for handball. Joe Bennett restarts play with the free kick.46:47
Nicky Bailey challenges Craig Conway unfairly and gives away a free kick. The ball is swung over by Peter Whittingham, Andrew Taylor produces a left-footed shot from deep inside the penalty box which goes wide of the left-hand upright.45:01
The match restarts for the second half.45:00 +3:17 Half time
Half Time The first half comes to an end.45:00 +2:00
Kenny Miller is flagged offside by the assistant referee. Nicky Bailey takes the indirect free kick.45:00 +1:25
The referee blows for offside against Scott McDonald. Free kick taken by David Marshall.45:00 +0:21
Matthew Bates restarts play with the free kick.45:00 +0:21 Booking
Booking The referee cautions Filip Kiss for unsporting behaviour.44:59
Unfair challenge on Nicky Bailey by Filip Kiss results in a free kick.43:07
Assist by Kenny Miller.43:07 Goal scored
Goal! - Aron Gunnarsson - Cardiff 2 - 1 Middlesbro Aron Gunnarsson scores a goal from deep inside the penalty area to the bottom right corner of the goal. Cardiff 2-1 Middlesbrough.40:49
Craig Conway produces a right-footed shot from outside the penalty box and misses left.38:53
Aron Gunnarsson concedes a free kick for a foul on Joe Bennett. Free kick taken by Julio Arca.37:01
Direct free kick taken by Don Cowie.37:01 Booking
Booking The referee shows Julio Arca a yellow card.36:39
Free kick awarded for a foul by Julio Arca on Kevin McNaughton.34:52
Kenny Miller gives away a free kick for an unfair challenge on Julio Arca. Rhys Williams restarts play with the free kick.34:09
Handball decision goes against Peter Whittingham. Faris Haroun restarts play with the free kick.33:07
Don Cowie produces a right-footed shot from deep inside the penalty area which goes wide of the left-hand post.32:39
Corner from the left by-line taken by Don Cowie, save by Jason Steele.31:26
Corner from the left by-line taken by Barry Robson, Matthew Bates concedes a free kick for a foul on David Marshall. David Marshall restarts play with the free kick.31:26 Substitution
Substitution Filip Kiss joins the action as a substitute, replacing Joe Ralls.29:13
Faris Haroun takes a shot. Blocked by Don Cowie.26:40
Don Cowie fouled by Julio Arca, the ref awards a free kick. Peter Whittingham crosses the ball from the free kick left-footed from right wing, save by Jason Steele.25:26
Direct free kick taken by Rhys Williams.25:26 Booking
Booking Peter Whittingham booked for unsporting behaviour.25:09
Foul by Peter Whittingham on Rhys Williams, free kick awarded.23:31
Barry Robson takes a shot. Save by David Marshall.23:16
Unfair challenge on Bart Ogbeche by Mark Hudson results in a free kick. Bart Ogbeche takes the free kick.22:12
Assist by Kenny Miller.22:12 Goal scored
Goal! - Ben Turner - Cardiff 1 - 1 Middlesbro Ben Turner finds the net with a headed goal from close in. Cardiff 1-1 Middlesbrough.21:22
Corner from the right by-line taken by Peter Whittingham, save by Jason Steele. Corner taken by Peter Whittingham from the right by-line to the near post,19:36
Free kick awarded for a foul by Barry Robson on Ben Turner. Mark Hudson takes the direct free kick.17:29
The official flags Justin Hoyte offside. David Marshall takes the indirect free kick.14:42 Goal scored
Goal! - Bart Ogbeche - Cardiff 0 - 1 Middlesbro Bart Ogbeche scores a goal from the edge of the penalty area to the bottom left corner of the goal. Cardiff 0-1 Middlesbrough.14:00
Peter Whittingham produces a left-footed shot from just outside the box that goes wide right of the goal.12:59
Peter Whittingham takes a inswinging corner from the right by-line played to the near post, Barry Robson makes a clearance.10:47
Handball decision goes against Craig Conway. Barry Robson crosses the ball in from the free kick, clearance made by Joe Ralls.7:45
Bart Ogbeche has a header from close range and clears the crossbar.6:30
Corner taken left-footed by Peter Whittingham from the right by-line, save made by Jason Steele.6:01
Peter Whittingham takes a shot. Blocked by Nicky Bailey.4:09
Shot from long distance by Kevin McNaughton misses to the right of the goal.3:37
Bart Ogbeche takes a shot. David Marshall makes a save.0:00
The ref blows the whistle to begin the match.
Live data and text provided by our data suppliers