Edinburgh (13) 25
Tries: Webster, Joiner, Warnock 2. Cons: Warnock. Pens: Warnock.
Scarlets (13) 16
Try: Byrne. Con: G Bowen. Pens: G. Bowen 2. Drop Goals: Phillips.
Edinburgh leapfrogged the Scarlets to claim top spot in the Celtic League after a hard-fought encounter at blustery Meadowbank.
It had looked as if the home side's domination of possession would count for nothing as the streetwise Scarlets used all their know-how to stay in touch.
But home stand-off Ally Warnock atoned for several missed kicks with a try double to give the Scots a deserved triumph.
The visitors from Lanelli took just three minutes to open the scoring, Salesi Finau sending Lee Byrne over, for Gareth Bowen to convert.
However, after Bowen and Edinburgh counterpart Warnock had traded penalties, the home side stormed ahead with two tries in quick succession.
Winger Simon Webster was first to breach the Scarlets' defence from Alan Jacobsen's pass and, five minutes later, Warnock finished off a fine move involving Ally Hogg and Graeme Burns.
However, Warnock's failure to convert either try enabled Michael Phillips to level the match with a drop goal on the stroke of half-time.
The Gunners, who had enjoyed the bulk of first-half possession, showed no sign of easing up on the restart and they notched their third try through former Scotland centre Craig Joiner.
Warnock converted before Bowen reduced the lead to 20-16 with a long-range penalty for the Scarlets.
However, Warnock sealed a famous win for Edinburgh when he broke through on the blind side to touch down with just a few minutes remaining.
Edinburgh: Lee, Webster, Joiner, Philip, Southwell, Warnock, Burns, Jacobsen, Kelly, Brannigan, Perrett, Kellock, Blackadder, A. Dall, A. Hogg.
Replacements: Di Ciacca, Smith, Strokosch, Cross, Lawson, Di Rollo, Sharman.
Scarlets: Byrne, Selley, Watkins, Finau, Rees, G. Bowen, Phillips, John, R. Williams, J. Davies, A. Jones, J. Griffiths, Cooper, G. Williams, E. Lewis.
Replacements: Maddocks, Yelland, B. Griffiths, C. Thomas, Boobyer, Burn, Evans.
Referee: A McKay