Fly-half Aled Thomas kicked a late penalty as Scarlets triumphed after Edinburgh’s fight-back from 19-6 down.
It was Thomas’ fourth penalty in a Scarlets performance that began brightly with Morgan Allen’s try.
Steve Shingler added a penalty before Thomas took over kicking duties.
Cornel du Preeze and Alex Toolis tries helped the visitors take the lead, but Scarlets held out after Thomas’ final kick as they dropped to fourth in the table.
Leinster’s bonus-point 52-0 win over Zebre sent them above Scarlets, while Edinburgh stayed fifth.
Lock David Bulbring made his Scarlets debut after arriving from South Africa while Kirby Myhill started at hooker.
Edinburgh made four changes as wing Damien Hoyland returned and Sam Beard was at centre for the injured Chris Dean.
Anton Bresler and Ben Toolis were a new-look second row for the Scots.
The home side seized the early initiative to build a 13-3 lead by the break. Allen was set free for his try, converted by Shingler before the fly-half added a penalty.
Fowles put Edinburgh on the scoreboard midway through the opening period with his first shot at goal and added a second soon after the break.
Thomas added two more penalties before Edinburgh’s fight-back began and Greg Tonks’ penalty rewarded Edinburgh’s momentum.
Replacement lock Toolis finished off in style out wide and Tonks’ conversion put them into the lead with six minutes left.
But Scarlets fought their way back upfield and were awarded a penalty that gave Thomas the chance to seal the win.
Scarlets head coach Wayne Pivac said: “We’re obviously happy and relieved. It was really important to get a win today with a couple of away games coming up.
“We were certainly disappointed to fall behind 21-19.
“That was a massive result; there was a big improvement, but still some errors.”
Scarlets: Michael Collins; Gareth Owen, Regan King, Hadleigh Parkes (c), DTH van der Merwe; Steven Shingler, Rhodri Williams; Phil John, Kirby Myhill, Peter Edwards; George Earle, David Bulbring; Aaron Shingler, Will Boyde, Morgan Allen.
Replacements: Ryan Elias, Dylan Evans, Rhodri Jones, Rory Pitman, Steff Hughes, Aled Davies, Aled Thomas, Steff Evans.
Edinburgh: Greig Tonks; Damien Hoyland, Michael Allen, Sam Beard, Tom Brown, Phil Burleigh, Nathan Fowles; Rory Sutherland, Neil Cochrane, John Andress, Anton Bresler, Ben Toolis, Mike Coman (c), Hamish Watson, Cornell Du Preez.
Replacements: George Turner, Allan Dell, Simon Berghan, Alex Toolis, Jamie Ritchie, Sean Kennedy, Blair Kinghorn, Dougie Fife.
Referee: Andrew Brace (IRFU)
Assistant Referees: Craig Evans, Greg Morgan (both WRU)
Citing Commissioner: Dennis Jones (WRU)
TMO: Jon Mason (WRU)