Italy led 6-3 at the break but Ireland took the lead when skipper Brian O'Driscoll scored a try three minutes after the restart that Jonny Sexton converted for a 10-6 lead.
From the restart Ireland were fortunate not to concede a try when Sergio Parisse almost intercepted Sexton's ill-judged pass to Gordon D'Arcy inside the Ireland 22.
Ireland should have extended their lead in the 56th minute when, with a clear overlap, Brian O'Driscoll, who otherwise had a fine game, flung a pass over Fergus McFadden's head into touch.
With seven minutes to go, Ireland were reduced to 14 when Denis Leamy was yellow carded, but crucially, O'Gara was at the helm by then, having replaced Sexton in the 65th minute, and once the Italians had taken the lead, it only remained for Ireland to work the space for O'Gara to weave his magic.
Neither were found wanting.