Preston capitalised on Keanu Marsh-Brown's early straight red, with first-half headers from Tom Clarke and Joe Garner before Gallagher slotted home.
The hosts had Stuart Beavon sent off, but on-loan forward Gallagher struck twice to complete his hat-trick.
Garner's low effort then competed the rout for the Lilywhites.
Despite Beavon's red card for a challenge on Andy Yiadom, good work after the break by Lee Holmes helped Gallagher to his second, before the former Scotland international beat the offside trap for his third.
Preston striker Paul Gallagher told BBC Radio Lancashire:
"I'm over the moon. Ten months is a long time to be not playing and last week I was over the moon just to be playing.
"To get a hat-trick and be in the next round of the FA Cup - I'm speechless.
"I'll enjoy tonight and then we'll wait and see who we get in the next round."
Paul Gallagher's hat-trick helped Preston thrash Barnet in an FA Cup first-round game which saw both teams finish with 10 men.