Predictably it was the League One high fliers who made the early running with Dominic Green forcing home keeper Dale Brightly in to action with a dangerous free kick in the second minute.
Hornchurch's first opportunity arrived in the ninth minute as Kris Lee found half a yard in the box only to fire over after Peterborough had failed to clear a corner.
The dangerous George Boyd then had a shot cleared off the line for the visitors before the non-league side had a goal chalked off after Dean Green was adjudged to have handled Lee's cross over the line.
But there was to be a late twist in the tale as Brightly spilt a seemingly straightforward Boyd strike from the edge of the box and Mackail-Smith was on hand to tuck home the rebound.
Posh will now face either Accrington Stanley or Tranmere in the next round.