Matthew Morgan scored all of the Welsh region's points in the first half as they took a 13-8 lead into the break, with the Scottish team's response coming through WP Nel's try and a Gregor Hunter penalty.
But the hosts dominated the second period and five more Hunter three-pointers gained a crucial win.
Although the Ospreys started the season in disappointing fashion, losing their first three matches in the Pro12, they have bounced back superbly.
Five consecutive victories leading into this encounter put them back in play-off contention. However, with both teams missing a number of internationals it was no surprise to see the game start in scrappy fashion.
Morgan's interception was the only action of note in the opening exchanges before the visiting stand-off edged them ahead after 16 minutes. Hunter levelled the scores soon after with a penalty, but the Welsh region's fly-half second from the tee regained their advantage.
Despite controlling the majority of the first half, the Ospreys were punished when the hosts' first real try-scoring opportunity ended in Nel touching down. Dougie Fife made the initial break before good hands from Richie Rees and Hunter sent the prop over.
Edinburgh's lead didn't last for long as Morgan crossed the whitewash after a spell of pressure to give them a deserved 13-8 lead at the interval.
Visiting prop Owen Williams was sin-binned at the start of the second period and Hunter added two three-pointers during that time to take the Scottish outfit ahead.
Further penalties from the home side's fly-half extended that advantage to 20-13. And Hunter sealed the win with a last minute kick from the tee.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The entire All Blacks apparel line has been updated for 2013/14. Check out the New Zealand All Blacks polo.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Gilbert Blitz 8S rugby cleat is a great cleat at a great price of $69.99. Get a new pair of cleats today.
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
The All Blacks Performance t-shirt is black with hints of blue from the training jersey. Very Cool.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.