Australian resolve broke Scottish hearts in a game of two halves in the first round of the IRB Under 21 World Championship at the Stade Darragon in Vichy.
Scotland led deep into injury time, but a try for Australia's Ulugia stole a likely victory away from John Jeffrey's men and put Australia in a strong position early on in the tournament.
The Scots led 14-0 at the break thanks to a try from Ross Rennie and three penalties from captain Blair but Australia refused to bow and fought back with 18 unanswered points of their own in the second period.
First they brought the score back to 14-13 down with a penalty by Lealifano and tries for Brown and Faingaa, before Ulugia's final dramatic effort swung the game in their favour.
Quotes
Chris Hickey, Australia coach: "I'm very happy with this win, which took a lot of sweat and tears to achieve. We had to improvise against a stubborn Scottish defence."
Julian Salvi Australia captain: "This first match was very difficult and a real eye-opener. We got some luck and had to call on all of our mental strength. There's plenty for us to work on going forward now."
Iain Paxton, Scotland coach: "I'm very frustrated and disappointed. It was ours to win and we let them back in. Too many errors. The back row got through a lot of work."
David Blair, Scotland captain: "I'm very bitter after that. We showed lots of passion and determination and had the victory there in our hands but ultimately paid for mistakes and lapses of concentration at key moments."