George Friend's 86th-minute own goal handed Cardiff a 1-0 win and three Sky Bet Championship points against Middlesbrough.
A game in which defences had been on top throughout appeared to be drifting towards a draw when Cardiff capitalised on late pinball in the Boro area. Goalkeeper Dimitrios Konstantopoulos saved Matthew Connolly's point-blank header but he was helpless when under a challenge from Joe Mason the ball struck Friend and flew into his net.
Both teams came into the game on the back of goalless draws and neither side had the clinical edge to break down durable defences at the Cardiff City Stadium. Middlesbrough have now gone now three games without a goal - their longest drought since March 2014 - but Grant Leadbitter was denied on the line by Lee Peltier's goal-line clearance 20 minutes from time.
The 13,371 crowd was the lowest league attendance in the six-year history of the Cardiff City Stadium, but Bluebirds' fans celebrated their lucky break at the end as they moved within a point of Middlesbrough in the Championship table. Cardiff were quick to pick up the second balls in and around the Boro box but most efforts were directed too close to Konstantopoulos.
The exception was Craig Noone's 12th-minute effort from 20 yards, which saw the former Cardiff keeper react quickly to his right to palm the ball away. But Middlesbrough defended well for most of the first half, with Konstantopoulos making regulation saves from Peter Whittingham and Matthew Connolly headers, while Alex Revell headed over from a corner.
Boro had struggled to get Stewart Downing into the game but Albert Adomah brought a point-blank stop from David Marshall and the visitors began to turn the screw towards the end of the first half.Cardiff had to deal with a succession of crosses from Boro's right flank and a clever free-kick created an opening for Adomah.Boro changed the angle of attack well and David Nugent met Leadbitter's diagonal ball to the far post, but Adomah was stretching and skied the loose ball over.
Aron Gunnarsson, leaning back, fired over for Cardiff soon after the re-start but Middlesbrough should have been ahead on 54 minutes when Connolly's error diverted the ball into the path of Adomah. The winger was through on goal but his shot was weak and Marshall did not have to move to gather, although the Scotland goalkeeper had to show smart reflexes to foil Diego Fabbrini.
And it proved costly at the end as Friend's own goal settled the contest in Cardiff's favour.