Wales burst Scotland's Guinness Six Nations bubble and put themselves back in title contention with victory at the Principality Stadium.
Scotland suffered an 11th successive defeat against Wales in Cardiff – a sequence that stretches back 20 years – as they failed to build on last weekend’s stirring Calcutta Cup win over England.
But Wales recovered impressively from a 29-7 loss to Ireland as captain Dan Biggar, on his 100th Test match appearance for Wales and the British and Irish Lions, inspired the victory.
Biggar, who battled on after taking a blow to his knee, kicked four penalties and a 70th-minute drop-goal after his opposite number Finn Russell was yellow-carded by referee Nic Berry for a deliberate knock-on.
Prop Tomas Francis scored a first-half try for Wales, while Scotland wing Darcy Graham touched down and Russell slotted four penalties, but with Russell off between the 68th and 78th minutes, they lost their talisman figure.
Scotland remain in the title hunt ahead of hosting France in two weeks – when Wales tackle England at Twickenham – yet there will be a huge sense of frustration that Gregor Townsend’s team could not get the job done.
There will be an anxious wait for Wales, though, surrounding flanker Taine Basham, who escaped sanction for a shoulder-led challenge on Scotland’s Sam Skinner, but could yet attract the citing commissioner’s attention.
Wales showed four changes from their Dublin defeat, including a Test debut for Ospreys flanker Jac Morgan and wing Alex Cuthbert making his first Six Nations appearance since 2017.
Scotland had five switches of personnel, with Exeter’s Skinner replacing an injured Jamie Ritchie at blindside flanker, while Townsend also fielded a new front-row and lock Grant Gilchrist won his 50th cap.
The visitors made a bright start, with number eight Matt Fagerson and hooker Stuart McInally prominent, but Wales counter-attacked from their own 22 through a thrilling Owen Watkin break, then Biggar kicked a fifth-minute penalty from 40 metres.
Biggar doubled Wales’ advantage three minutes later, booting a second penalty following more impressive Wales phase-play, and Scotland were rocked back on their heels.
But they responded impressively, helped by a strong Duhan van der Merwe run, then Russell floated a pinpoint long pass to Graham, who finished in the corner for an outstanding try.
Russell missed the conversion before landing a short-range penalty, and it looked as if Scotland had weathered an early storm as they moved 8-6 ahead.
Another successful Russell penalty gave Wales further food for thought as rain fell steadily, only for Biggar to complete his penalty hat-trick and put his team back to two points adrift.
Russell followed suit through his own penalty treble, yet Scotland then experienced a testing few minutes as number eight Matt Fagerson went off injured then Wales hit them with a try.
Biggar opted to kick a penalty to the corner rather than for goal and Wales drove the resulting lineout to impressive effect, allowing Francis a simple touchdown that levelled things up at 14-14.
Townsend sent on a trio of front-row replacements just five minutes into the second period, and Russell’s fourth penalty put Scotland back in front with 30 minutes left.
Biggar and impressive full-back Liam Williams gave Wales injury scares, but they both continued after treatment and Cuthbert went close to scoring a try before another Biggar penalty levelled the game again.
Scotland suffered a second injury blow midway through the half when substitute prop Rory Sutherland departed, then Russell was sin-binned after Cuthbert was inches away from a corner touchdown.
Before the Scots could regroup, Biggar rewarded a spell of pressure with a drop-goal, before he was joined on the pitch by substitute Jonathan Davies, who also clocked up a century of Wales and Lions Tests.
Scotland threw everything at Wales during the closing minutes, but the hosts were not to be denied.