Jonathan Sexton kicked two penalties for the visitors, with Chris Paterson replying once for the Scots in a hard-fought and low-scoring encounter.
But in the dying moments Nick De Luca made a break and put Northampton Saints star Ansbro away.
The visitors made 13 changes to the side that finished the Six Nations with a stirring victory over
Nikki Walker had the home crowd on their feet after a fourth-minute line-break but Ruaridh Jackson threw away possession.
Graeme Morrison was the next to come close but he was held at bay by some sterling Irish defence.
Jackson and Chris Paterson combined to set up Walker in the corner but 2009 Lion Rob Kearney did enough to force a the mistake with the line at the Scot's mercy.
Walker left the field after 20 minutes with a head injury and Jack Cuthbert came off the bench for his first Scotland cap.
Ireland offered little in attack but took the lead through Sexton on 33 minutes, to hand Ireland a 3-0 lead at the interval.
Paterson, with his sights set on a fourth World Cup, levelled the game through the boot on 49 minutes.
Sexton nudged Ireland ahead again with a long-range penalty before he and Paterson missed further chances. But the game was sealed with Ansbro's late try.