The Scots seemed to be cruising to glory as they led 30-13 going into the final stages only for Leinster to battle back strongly.
But stand-in skipper Nathan Hines grabbed the late counter which set up a long-awaited capital success.
Stand-off Ander Monro broke the deadlock with a crisply struck long-range penalty then Derrick Lee bagged the first touchdown.
Argentina star Felipe Contepomi eased the Leinster jitters with a confidently struck penalty only to watch Lee complete his try double after fine work by Mike Blair and Hines. Monro clipped over the conversion, with Contepomi again replying with a penalty to keep the Irish side in the hunt.
But they fell further behind on the half-hour mark as Matt Dey dodged his way over from 15 metres for his first pro-game try.
Hugo Southwell grabbed the all-important fourth try on the stroke of the break with Monro converting.
Leinster gave themselves a glimmer of hope after the restart when flanker Neil Ronan capitalised on a missed touch-kick by Lee. His try was goaled by Contepomi. Monro's penalty should have killed off the Irish challenge, but they produced a stirring fightback to narrow the gap to just three thanks to touchdowns by Christian Warner and James Norton, converted by Contepomi. Then came the Hines clincher, with Monro adding the kick to make sure.
The frantic action continued as Des Dillon pulled back another try for Leinster, converted by Contepomi, but Southwell had the last word with a penalty for Edinburgh in the 10th minute of stoppage time.
: Lee, Southwell, Di Rollo, Dey, Joiner, Monro, Blair, Smith, D Hall, Brannigan, Hines, Kellock, Strokosch, Cross, A Dall.
Edinburgh scorers: Tries: Lee 2, Southwell, Hines, McGee. Cons: Monro 3. Pens: Southwell, Monro 2.
: Norton, McWeeney, Warner, Contepomi, Burke, Leek, O'Meara, Coyle, G Hickie, Brophy, C Potts, Gissing, Dillon, Ronan, Costello.
Leinster scorers: Tries: Norton, Warner, Dillon, Ronan. Cons: Contepomi 4. Pens: Contepomi 2.