A late penalty from Finn Russell condemned Cardiff to a third consecutive defeat in a dismal start to their Guinness PRO14 season.
Despite the loss it was a better performance from the Blues but Glasgow were always the more inventive side and deserved their success.
Henry Pyrgos and Lee Jones scored tries for Glasgow with Russell converting both and adding two penalties.
Tom James scored Blues' try with Steven Shingler kicking four penalties and a conversion.
Glasgow dominated the early stages but on their first excursion into the opposition half, Blues took the lead.
The Scots lost a line-out for Josh Navidi to drive forward and when the ball was recycled, James skated through the defence for an excellent solo try.
Shingler was on target with the conversion and minutes later extended the Blues' lead with a penalty.
Russell responded by putting his side on the scoreboard with a penalty to leave Glasgow trailing 10-3 at the end of the first quarter.
However, Glasgow were their own worst enemies in the first half hour as they tried to be too intricate, resulting in numerous mistakes when up against some resolute tackling from Blues.
Shingler's second penalty put Blues further in front before flanker Callum Gibbins made Glasgow's best break of the half, but a strong tackle from James snuffed out the danger.
Glasgow's enterprise was eventually rewarded when a flowing move was finished off by Pyrgos for a splendid try.
Soon afterwards they should have had another. From inside his own 22, Nick Grigg evaded Shingler's tackle to run 60 metres but Glasgow lacked the accuracy to cross the try-line and so trailed 13-10 at the interval.
Early in the second half, another careless error from the Scots gifted Shingler another three points but from the restart Glasgow took the lead for the first time.
Russell expertly collected a clearance kick by jumping ahead of Alex Cuthbert to send Jones on a 25 metre run to the line.
The visitors' lead was short-lived as Shingler knocked over another penalty.
Glasgow had much the better of territory and possession in the third quarter but the concession of regular penalties stopped them taking advantage and they were still behind 19-17 with 20 minutes remaining.
A scrum penalty saw Russell put Glasgow in front after 66 minutes. Shingler had a chance to win the match but his penalty attempt sailed wide with 90 seconds left on the clock.