Posh endured a frustrating evening at Huish Park but finally made the breakthrough with five minutes left when Mackail-Smith turned past Paul Huntington before firing home.
And they made sure of victory in the 89th minute when Grant Basey blasted in from close range after Yeovil failed to clear a Grant McCann corner.
The Glovers were made to pay for missing a series of chances in the first half, with Sam Williams slicing the ball wide from close range.
Peterborough were also indebted to goalkeeper Joe Lewis for crucial saves to deny Andy Williams and Oli Johnson before the break. But it was the visitors who dominated the second period, and George Boyd and Nathaniel Mendez-Laing came close to breaking the deadlock before Mackail-Smith's strike.
Yeovil also felt a sense of injustice when Gabriel Zakuani was shown a yellow rather than a red card when he pulled back Andy Williams as the strike bore down on goal.