Two tries by Rory Scholes and one for Neil Cochrane had put Edinburgh 17-6 up but they conceded twice in the last 15 minutes to end up losing by a point.
At the end of a week which began with the news that former Leicester director of rugby Richard Cockerill will be taking over as head coach next season, it came as a blow as the Pro12 campaign lurches from bad to worse. Cardiff opened the scoring through a Steven Shingler penalty before the Welsh suffered a yellow card to tighthead Anton Peikrishvili for side entry and Edinburgh took full advantage with a ferocious drive that skipper Cochrane finished off and Sam Hidalgo-Clyne converted well for a 7-3 lead.
But Shingler responded almost immediately with another penalty to cut the lead to a single point.
Hidalgo-Clyne had an opportunity to extend the advantage in the 25th minute but he narrowly missed from just over 40 metres out.
Cardiff’s indiscipline continued and another yellow was forthcoming on the half-hour mark, this time for lock Jarrad Hoeata.
Edinburgh made a strong start to the second period, however, and had the second try in the bag in the 49th minute when a slick handling move put Scholes away down the right and he showed great speed and strength with a hand-off to hare in at the corner.
Hidalgo-Clyne couldn’t make the difficult touchline conversion but it was the scrum-half who made the decisive contribution to Scholes’ second try of the night.
Edinburgh had pounced on a mix-up in the Cardiff midfield and put a patient set of phases together before Hidalgo-Clyne’s clever reverse pass had the winger over in the left corner this time.
It left yet another testing wide conversion and again it drifted just past the wrong side of the post but the lead was now 11 points.
Cardiff took a huge chunk out of that just after the hour mark when Josh Sion Bennett finished off a good offloading move under the posts and Shingler’s conversion made it 17-13.
Heading into the last ten minutes Edinburgh were reduced to desperate defending and succumbed when scrum-half Lloyd Williams’ chip ahead bounced into his hands under the posts but the conversion was charged down to have the visitors a point ahead.
Blair Kinghorn couldn’t land a long-range penalty and Edinburgh could not work another chance as time ran out.