The home side looked in serious trouble coming up to the break after tries from Xavier Rush and George Smith, - added to three Brock James penalties - saw them trail 21-3, a lead the tourists fully deserved.
However, a chink of light appeared when O'Gara cleverly switched play in midfield to create the space for Ronan's try and offer his side a way back into this game.
O'Gara almost gave Ireland the perfect start with a penalty within two minutes of the restart, his effort just striking the wrong side of the left upright and then it required a last gasp Paul Warwick tackle on Sean Cronin to prevent a certain try.
O'Gara was on target with his next effort but then Cedric Haymans scored in the left hand corner and replacement Jean Baptiste Elissalde added a penalty.
Ireland's looked destined for certain defeat when Haymans again broke free and only a last gasp Johne Murphy tackle saved a certain try.
At this stage Declan Kidney introduced Munster trio Jerry Flannery, Mick O'Driscoll and Donncha O'Callaghan and the move had an immmediate positive effect.
O'Gara landed another penalty and converted Tony Buckley's try to set up a granstand finish as the tourists began to run out of steam.
Ireland: R Kearney; J Murphy, G Duffy, F McFadden (P Wallace ht)., A Trimble; R O'Gara capt, P Stringer; M Horan, S Cronin, T Buckley; E O'Donoghue, D Tuohy; J Muldoon, N Ronan, C Henry. Replacements: J Flannery, T Court, M O'Driscoll, D O'Callaghan, T O'Leary, T Bowe.
Barbarians: P Warwick; D Smith, C Lualala, S Rabeni, C Heymans; B James, P Mignoni; D Barnes, S Brits,C Johnston; J Thion, M O'Kelly; A Quinlan, G Smith, X Rush. Replacements: B August, J White, R So'oialo, M Williams, B Kelleher, J-B Elissalde, F Estebanez.