Wales recorded their ninth successive victory over Scotland in the RBS 6 Nations Championship to stay firmly among this season's title contenders.
But they required late tries at the Principality Stadium from centre Jamie Roberts and wing George North to subdue an impressive Scottish performance.
Scrum-half Gareth Davies also touched down for Wales, courtesy of a magnificent early break, while fly-half Dan Biggar added three conversions and two penalties as Scotland's long wait for a win in Cardiff continued.
Outstanding wing Tommy Seymour and centre Duncan Taylor scored tries for Scotland, with skipper Greig Laidlaw adding eleven points from the boot and Duncan Weir kicking a late conversion.
Yet they were ultimately outgunned during a game that saw them lose full-back Stuart Hogg - their sharpest attacking threat - due to a back injury.
Wales, after a draw in Dublin last weekend, will go top of the championship if they beat next opponents France, but Scotland have lost two from two, following an opening 15-9 defeat at home to England.
While Wales went in with an unchanged team from Dublin, Scotland announced a late switch as London Irish wing Sean Maitland missed out because of hamstring trouble. Sean Lamont moved off the bench to replace him.
A closed stadium roof greeted Scotland's first Cardiff visit since they were crushed by a record 51-3 margin two years ago, while Wales were led out by centre Jonathan Davies on the occasion of his 50th cap.
The home opened the scoring in spectacular fashion after seven minutes when centre Jamie Roberts knocked possession back following an aerial collision.
Davies pounced from 40 metres, outpacing Scotland's defensive cover to claim a sixth try in his last seven Test appearances.
Biggar (above) added the conversion for a 7-0 lead after as many minutes but Scotland hit back when Russell kicked cleverly into space and Seymour finished in the corner before Laidlaw's conversion tied things up.
The Dark Blues suffered a major injury blow eleven minutes before the break when Hogg went off to be replaced by Jackson. Yet it did not unsettle them as Laidlaw kicked a long-range penalty, making it 10-7.
Although Biggar quickly wiped out the deficit with a penalty, Laidlaw accepted another chance on the stroke of half-time and Scotland deservedly held the interval advantage – 13-10.
Wales began the second period in determined fashion and Biggar's second successful penalty brought them level.
Scotland regained some initiative when Wales full-back Liam Williams slipped and knocked on just outside his own 22, and the visitors gained a scrum penalty that Laidlaw (below) landed to restore a three-point lead.
Wales skipper Sam Warburton opted against taking a close-range penalty for another scrum, and the game had unquestionably arrived at a key moment.
This was confirmed when Roberts smashed his way over and Biggar's conversion put Wales four points clear.
North then sealed it for Wales as the clock ticked down, although Taylor added a later try for Scotland, setting up a Cardiff showdown with unbeaten title rivals France on Friday, 26 February.