Munster 19-16 Edinburgh
The fly-half also created Denis Leamy's first-half try as Munster claimed their first win in four matches.
Allan Jacobsen's try helped Edinburgh get on terms at 13-13 by half-time.
David Blair hit 11 Edinburgh points and his final penalty put the visitors ahead after the break but O'Gara's two late penalties ensured Munster's win.
O'Gara kicked Munster in front in the third minute but, despite bossing the game up front, the home side had little to show for their efforts on the scoreboard.
Blair levelled for Edinburgh with a penalty but the Scottish side then lost hooker Ross Ford to the sin-bin as he slowed up Munster ball following a Peter Stringer break.
O'Gara knocked over the resulting penalty but Edinburgh, still hunting for their first league win under new coach Andy Robinson, levelled again courtesy of an excellent Blair drop goal.
A moment of magic from O'Gara then prized open the Scots' defence for Leamy's try.
The number 10's right-footed dink to the left corner was gathered by Leamy on the deck and the back rower's momentum allowed him to make the line.
O'Gara converted but, four minutes before the break, Edinburgh got back on terms.
Neat inter-linking between Hugo Southwell and Andrew Turnbull set up ruck ball near the right corner, and Blair spun the ball back for prop Allan Jacobsen to crash over the line.
Blair nudged the visitors in front with a 64th-minute penalty but the Scots' discipline ultimately let them down.
Jacobsen was sin-binned for pulling down a maul, allowing O'Gara to level on 75 minutes and a ruck offence from Rennie then led to the Munster fly-half firing over the match-winning kick from 42 metres with a minute left.