Leeds academy product Kalvin Phillips marked his home debut with a goal but Neil Redfearn’s side are without a win against Cardiff in 17 matches.
Midfielder Phillips, who made his first senior appearance five days earlier at Wolves, gave an energetic performance, to the delight of the home crowd who gave him an ovation when he was substituted soon after the hour.
The 19-year-old struck just three minutes after Sean Morrison had given Cardiff a 14th-minute lead, but Gunnarsson snatched a 62nd-minute winner for Russell Slade’s men.
There was an unusual atmosphere, with Cardiff backing their fans’ boycott of the match in a row over the Bluebirds’ ticket allocation. So when defender Morrison forced the ball home at point-blank range the goal was greeted in total silence.
Former Leeds captain Lee Peltier played his part in the build-up by being first to Peter Whittingham’s corner from the left but Peltier’s old club rapidly drew level in storybook fashion.
Scotland international keeper David Marshall slipped as he came off his line and Phillips kept a cool head to slot Charlie Taylor’s left-wing cross into an unguarded net before setting off on a jig of celebration.
Cardiff lost the dazed Conor McAleny with 33 minutes gone, Eoin Doyle leaving the bench, and the former Chesterfield striker was the victim of two desperate saves by Marco Silvestri.
Doyle had been on the pitch for just two minutes when Leeds defender Sol Bamba played a careless back-pass into his path but Silvestri stood his ground and palmed the Irishman’s shot round a post.
Doyle should also have scored just before half-time when Leeds failed to cut out Whittingham’s left-wing corner, leaving Doyle with only Silvestri to beat at the foot of the far post, but again the Leeds keeper sprang to the rescue with a stunning block.
Joe Mason was also guilty of a bad miss, driving wide of the far post when well placed as Cardiff went in at the interval regretting their missed opportunities.
Joe Rolls was the next to let Leeds off the hook as he failed to tuck away Craig Noone’s penetrative pass, but the home side’s luck ran out when Silvestri parried yet another shot in the congested goalmouth and Gunnarsson got the final touch.
Leeds made a double substitution, sending on strikers Billy Sharp and Steve Morison in place of Mirco Antenucci and Phillips with 25 minutes remaining.
Sharp headed against the bar almost immediately and Morison sent a header into the crowd, but Leeds could not stave off a third successive defeat and are without a win over the Welshmen for 31 years.