Lleucu George had the chance to level the scores in the final minute after Alex Callender scored late to drag the hosts back into contention.
But the fly-half was unable to convert and Scotland were able to emerge with a statement victory in the Championship despite their late scare.
Tries from Coreen Grant and Rhona Lloyd proved the difference in a closely-fought encounter in the Welsh capital, with neither side able to truly stretch clear of their opponent at any stage of the absorbing contest.
Five of the previous six Championship meetings between these sides had been decided by fewer than seven points, and it was clearly early on that this would be another close affair.
Grant’s scintillating try six minutes in set the match alight, with the boot of Keira Bevan keeping the hosts in touch at the break.
Another flowing move after the restart yielded Scotland’s second try as they looked set to see home a comfortable victory but Sisilia Tuipulotu’s try for Wales made sure that would not be the case.
Callender then scored another to give George the chance to equalise and rescue a point for the hosts but her kick was wayward leaving Scotland jubilant at full-time.
GRANT SETS CONTEST ALIGHT
Wales were the first on the scoreboard as Bevan slotted home a penalty after just six minutes but Scotland responded in perfect style just a minute later though Grant’s try.
It all stemmed from a lineout just inside the Welsh half, with quick ball through the phases allowing Bryan Easson’s side to march up the pitch before the wing raced past three defenders wide on the left to dot down.
Helen Nelson added the extras to put the visitors’ lead out to four before and the fly-half put on another three with the boot after the Welsh defence was penalised at the breakdown with Scotland just five metres from the line.
Grant was then involved again, sauntering down the wing from deep inside her own half before finally being stopped by Jasmine Joyce with a try-saving tackle.
It was representative of Scottish dominance in the first half, but some loose hands at the lineout saw several chances inside the Welsh 22 go begging in search of a second try.
Yet for all their territorial dominance, Scotland were unable to find a way through and Wales slowly worked their way back into the contest.
Scotland scrum-half Caity Mattinson was caught trying to run the ball out from the back of a ruck and that provided the basis for a rare Welsh foray into the 22.
A rolling maul looked to be heading over the whitewash but was well held up on the line by the Scottish defence.
That seemed to spark Wales into life, as they ended the half on top and Bevan slotted home another penalty to reduce the deficit to four at the break.
LLOYD STRETCHES LEAD BEFORE GRANDSTAND FINISH
Scotland hit back after the break and had their second try just under 10 minutes after the restart through Lloyd.
Evie Gallagher stole the ball at the breakdown before Emma Orr produced a stunning break to scythe through the Welsh defence and release Lloyd to ride a tackle and score in the corner. Nelson added the extras with an impressive conversion out wide.
The visitors were immediately on the attack again thanks to a brilliant 50:22 from Lisa Thomson but the Welsh defence stood strong as the home side looked for a way back into the contest.
It came in the form of Tuipulotu who powered her way over from close range after a sustained period of pressure on the Scottish line.
The hosts ran through the phases time and time again but were repeatedly held up by a stoic Scottish defence, before Tuipulotu finally found a gap and Bevan added the extras to make it a four-point game once more on the hour.
Scotland looked to immediately respond and put the Welsh line under intense pressure but the hosts were able to hold the ball up on the line after Gallagher looked to have burrowed over.
But the Scots reset from a penalty as they searched for a third try, Mattinson dictating the tempo as the visitors crunched through the phases inside the Welsh 22 but they were again unable to find a way through.
With no way through coming with the ball in hand, Nelson added another three points from the tee after a Welsh infringement at the scrum to stretch the lead out to seven with six minutes left on the clock.
Wales pushed hard to try and level the match at the death, Lleucu George produced a cross-field kick to try and release Nel Metcalfe before Scotland’s Alex Stewart saw yellow for an infringement as the visitors desperately sought to cling onto their lead.
But the pressure eventually told as Callender found a way through with just two minutes left on the clock to reach over the try line.
But George was unable to score the crucial conversion to leave the home side two points short of parity.