Rhys Priestland's late penalty gave Scarlets the narrowest of wins against Edinburgh at Murrayfield.
Tim Visser crossed for the hosts early on but Scarlets led 26-19 at the break.
Two tries from George North in addition to those by Nick Reynolds and Gareth Davies secured a bonus point for the Welsh side.
Harry Leonard added three penalties to his first-half tally to put Edinburgh ahead again but the home side were undone by Priestland on 79 minutes.
And, though Michael Bradley's side pick up a bonus point, it will be little consolation after a sixth straight defeat.
Second-place Scarlets are now just a point behind Pro12 leaders Ulster, who have a game in hand.
Having suffered two heavy defeats to nil in the Heineken Cup, Edinburgh were determined to reverse their poor form and went ahead when Visser powered through two tackles to touch down between the posts and leave Leonard with a straightforward conversion.
But the Scottish side's defensive frailties were exposed again when right wing North appeared on the left flank to burst over the line and Aled Thomas's conversion levelled.
Leonard's first penalty temporarily put the home side ahead again but Edinburgh did not deal with Davies's run following a scrum, with the scrum-half offloading for Reynolds to plunge over. Thomas converted again.
Two more successful penalties by Leonard were followed by North's touchdown in the corner and the Edinburgh fly-half's fourth successful kick levelled the scoreline.
However, a handling error by Leonard allowed Davies to cross and another Thomas conversion gave Scarlets a seven-point advantage at the turnaround.
A first miss of the night by Leonard was soon atoned for after Davies had been sin-binned for an angry reaction during an exchange with Greig Tonks.
And Leonard's sixth and seventh successful penalties edged Bradley's men in front and on course for a morale-boosting win.
But Scarlets responded with a wave of pressure in the closing stages and Thomas's replacement Priestland kicked the decisive kick.
Edinburgh: Tonks, Jones, Scott, Houston, T. Visser, Leonard, Leck, Yapp, Titterrell, Nel, Gilchrist, Cox, Denton, Rennie, McInally.
Not Used: Ford, Hislop, Allen, McAlpine, Grant, Rees, Fife, Brown.
Scarlets: L. Williams, North, Reynolds, S. Williams, Stoddart, A. Thomas, G. Davies, John, Rees, Lee, Timani, Vallejos, Shingler, J. Edwards, McCusker.
Replacements: Owen for L. Williams (63), Priestland for A. Thomas (56), Hopkins for John (63), Owens for Rees (72), Kelly for Vallejos (76), Murphy for McCusker (72). Not Used: Manu, A. Davies.
Ref: Marius Mitrea (Italy).