The full-back, a stand-out player at last summer's Junior World Championship in France, produced some dazzling footwork in a match that was lacking in star quality with so many internationals on RBS 6 Nations duty.
Edinburgh had threatened an upset when they led 10-0 early in the game, but the Scarlets were able to produce a determined rearguard and will be disappointed not to have claimed a try bonus point late on.
Only two places separated the sides in the table going into the match, with the Scarlets desperate for a big win to maintain their outside chance of a play-off spot and also keep ahead of one of their rivals in the race for potential European places next season.
However, it was the visitors who started with far more urgency and were celebrating the game's first try after just three minutes.
With full-back Jack Cuthbert breaking tackles, Tom Brown was freed on the left wing and, although his inside pass failed to find its intended target, Edinburgh re-gathered well and centre Nick de Luca plunged over from short range.
South African fly-half Carl Bezuidenhout converted from the touchline, and then added a penalty to make it 10-0.
The Scarlets did eventually awake from their slumber with a downfield punt from Aled Thomas leading to a penalty which the fly-half converted.
Thomas added a second from straight in front after good pressure from the home pack, but it was scrum-half Gareth Davies - the league's leading try-scorer - who provided the spark just before the half-hour mark.
Davies scythed through from halfway and, with the Edinburgh defence stretched, the ball was delivered wide to man of the match Williams, who was able to stroll over unopposed.
Thomas converted, but Edinburgh were level almost immediately with Bezuidenhout landing a 45-metre penalty after the Scarlets had been caught offside.
It was the home side, though, who went in at half-time in the ascendancy thanks to a moment of individual brilliance from Williams, who skipped inside a couple of defenders before turning on the pace to claim his second of the afternoon.
That made it 18-13 at the interval - a lead which lasted barely four minutes after the restart.
A great break from scrum-half Grayson Hart put the visitors deep into home territory and it was Brown who did well to step inside two defenders to score after a fine pass from replacement Harry Leonard had opened up the Scarlets' back line.
In a see-sawing contest, it was no surprise that the home side were next on the board.
The Scarlets, with prop Phil John to the fore, rumbled up to the try-line and centre Adam Warren shrugged off a tackle to dive over.
Thomas converted, but the Scarlets were unable to shake off the Scots with Cuthbert reducing the arrears to four points with a penalty.
Both sides had try-scoring opportunities in the final minutes, but it was the Scarlets who held on for another much-needed win.
- Sports & Recreation