Scotland was the better side for much of the opening 40 minutes in Dublin but fell behind to Keith Earls' try just before the interval.
Earls touched down again after the break, with Cian Healy getting in on the act to cement Ireland's lead.
Duhan van der Merwe hit back for Scotland but Ross Byrne kicked two late penalties to keep the visitors at bay.
Wales took fifth place with a 38-18 victory over Italy at Parc y Scarlets.
The hosts had surrendered a 14-0 lead to trail 18-17 in the second half before Justin Tipuric and Taulupe Faletau combined brilliantly to set Gareth Davies away for a pivotal try.
Italy did not have a second fightback in it and Wales put the game to bed with two further scores from George North and Tipuric.
Elsewhere, Nemani Nadolo scored a hat-trick for Fiji in its 38-24 win over Georgia, securing seventh spot for the Pacific island side after a six-try haul.