Their success came thanks to two outstanding tries from Netani Talei and Tim Visser, with James Thompson adding a late third and David Blair kicking the rest of their points.
Glasgow scored one try, another memorable effort from Robert Harley, while Ruaridh Jackson and Colin Gregor kicked two penalties each. Jackson, though, missed a conversion and two penalties in the first half.
Glasgow made the better start, with Jackson kicking two penalties from distance. However, two stunning tries from the home side propelled them into a 12-6 lead, and Magners League top try scorer Visser had a hand in both. The first stemmed from a lineout with Visser carving up centre field before putting Talei in under the bar.
Seven minutes later, Talei attacked off a scrum in his own half and the move ended with Visser touching down for his ninth of the season.
Glasgow clawed back five points through a fine touchdown by flanker Harley. However, Jackson missed the conversion and also failed with two penalties.
Two Blair penalties widened the gap to 21-11, but Glasgow found another gear in the closing stages that made for a tight finish until Thompson’s breakaway try in stoppage time.
Edinburgh scorers: Tries: Talei, Visser, Thompson. Cons: D. Blair 2. Pens: D. Blair 3.Glasgow scorers: Try: Harley. Pens: Jackson 2, Gregor 2.
EDINBURGH: J. Thompson; L. Jones, B. Cairns, J. Houston, T. Visser; D. Blair, G. Laidlaw; A. Jacobsen, R. Ford, G. Cross; C. Hamilton, F. MacKenzie; R. Grant, R. Rennie, N. Talei.
Replacements: S. Webster for Jones (56), N. De Luca for Cairns (52), M. Blair for Laidlaw (44), K. Traynor for Jacobsen (52), D. Young for G. Cross (56), S. Turnbull for MacKenzie (62).
GLASGOW: B. Stortoni; H. O’Hare, M. Evans, P. Murchie, DTH van der Merwe; R. Jackson, C. Gregor; J. Welsh, F. Thomson, M. Low; R. Gray, A. Kellock; R. Harley, J. Barclay, R. Vernon.
Replacements: F. Aramburu for O’Hare (56), P. Horne for Murchie (68), H. Pyrgos for Jackson (52), R. Grant for Welsh (53), D. Hall for Thomson (52), K. Tkachuk for Low (56), A. Muldowney for Kellock (65), R. Wilson for Vernon (56).
Referee: N. Paterson (Sco).