Hal Luscombe and Mike Brown both scored for Quins but they rarely looked like ending their run of ten games since their last win in the Heineken Cup, against Bridgend back in 2002.
The Blues knew victory would keep them in the mix for qualification and they showed their intention early but centre Dafydd Hewitt saw his fourth minute touchdown ruled out for crossing.
That did not dissuade the Blues from attacking at every chance. Another series of surges towards, Tom Shanklin involved three times, took the home side within striking range again but had to settle for three points from Ben Blair.
Harlequins gradually stemmed the tide after a distinctly shaky opening but Chris Malone twice missed the chance to equalise with penalties on 27 and 35 minutes. Quins were made to pay for their missed kicks as Cardiff finally broke their line after Mike Brown made a hash of his clearance.
That handed the Blues a foothold in the Quins half and from Deiniol Jones's tap from the resulting line-out, Martyn Williams sent centre Dafydd Hewitt cruising through from 20 yards out to score under the posts three minutes before half-time. Blair's conversion handed the hosts a 10-0 lead at the break.
Harlequins hit back in the second half when Wales wing Luscombe dived over on 50 minutes following Brown's break. But discipline let the Londoners down as Blair kicked two more penalties, the second after De Wet Barry was shown the yellow card for a high tackle on Nick Macleod.
That nudged the Blues out of reach but it took Shanklin's score nine minutes from time to puts the wraps on the win, shoved over from close range by the home pack before Brown's late consolation score.