Nigel Davies’ men trailed by 20-6 at half-time but fought their way back level thanks to tries from Andy Fenby and Jon Davies.
But Greig Laidlaw slotted a penalty in the final ten minutes to snatch a dramatic victory at Murrayfield.
Rhys Priestland opened the scoring for the Scarlets with an early penalty at Murrayfield but Greig Laidlaw quickly booted the hosts into the ascendancy with two of his own.
David Denton stretched Glasgow’s lead with a barnstorming try on 21-minutes, with Laidlaw again on target to bring the scores to 13-3.
Priestland hit back for the hosts but the Scarlets were dealt a major blow when both Deacon Manu and Matthew Rees were sent to the sin-bin within minutes of each other following persistent infringements.
And the 13-man Scarlets eventually buckled under the pressure of their numerical disadvantage as Edinburgh were awarded a penalty try on the stroke of half-time.
Laidlaw slotted the straightforward conversion as the Scarlets entered the interval trailing by 20-6.
Priestland slotted his third penalty as the Scarlets returned to full-strength and they continued their resurgence with Fenby’s converted try.
Laidlaw responded for the hosts to bring the scores to 23-16 but Davies raced clear to put the Scarlets within touching distance, with Stephen Jones converting.
But it was not quite enough as Scotland international Laidlaw landed a late penalty to secure a narrow victory.
Â