Jamie Masson struck a hat-trick as Buckie's Highland League rivals, Formartine United, also hit the goals trail by hammering Banks O'Dee 7-2.
Formartine will host Annan Athletic after the League Two side came from behind to beat East Stirlingshire 2-1.
Forres Mechanics beat Cumbernauld Colts 4-0 in the other replay.
The Highland League side will host Stenhousemuir, of League One, in the next round.
Lowland League side Cumbernauld, making their cup debut this season, found themselves behind after a minute, with Stuart Soane, Lee Fraser and Kyle Scott adding to Craig McGovern's opener in the final 20 minutes.
McLeod scored twice in the first 10 minutes for Buckie in Gretna, but the Highland League leaders were reduced to 10 men when Stuart Taylor was sent off after 45 minutes.
Dylan Neill pulled one back for the Lowland League side shortly after the break, but McLeod scored three more before Johnny Murray grabbed Gretna's second.
Neill was himself sent off for serious foul play with 14 minutes remaining and Craig Dorrat rounded off the scoring for Buckie in the closing seconds.
Paul Sludden put Shire, who lost their Scottish Professional Football League status last season, ahead after 31 minutes at home to Annan.
However, David McKenna equalised five minutes later and Adam Asghar struck the winner in stoppage time before the Lowland League side's Andrew Rodgers was sent off for a second bookable offence.
Jack Henderson gave North Superleague juniors Banks O'Dee the lead after four minutes against Formartine, but Stuart Anderson and a Masson double put the home side in control.
Craig Buchanan reduced the arrears, but Neil Gauld restored the two-goal advantage before the break.
Goals from Graeme Rodger, Scott Barbour and former Aberdeen midfielder Masson, completing his hat-trick, secured the win in the final 15 minutes.
Striker John McLeod scored five times as Buckie Thistle secured a Scottish Cup third-round tie against Dunfermline Athletic by thrashing Gretna 2008 6-2.