Rangers looked to be home and hosed when they went 3-0 up against Dumbarton at the C&G Systems Stadium thanks to first-half goals from Jake Hastie and Alex Lowry and a third from Tony Weston.
But Gregor Buchanan pulled one back for the hosts on 87 minutes after good work by Callum Wilson and the 18-year-old set up Eoghan Stokes for a second in the first minute of injury time to set up a frantic finale, with the Gers holding on to advance to a second-round encounter against Ayr United.
Celtic found it easier going against Annan Athletic at the Penny Cars Stadium with Lee O’Connor opening the scoring after just three minutes and Scott Robertson doubling the Celts’ advantage with 15 minutes remaining to set up a home tie against Greenock Morton in the next round.
Falkirk will travel to Kilmarnock after a comprehensive 3-0 victory against East Kilbride at K Park. Steven Old put through his own net on the half-hour mark, Seb Ross netted the Bairns’ second just before the hour, and Aidan Keena put the game beyond all doubt with around 20 minutes remaining.
Ross Alexander's first-half goal was enough to secure Broomhill a shock victory over League One Clyde at the Indodrill Stadium. The Bully Wee threw everything at their Lowland League opponents with goalkeeper Stephen Barr saving well from Robert Jones before pulling off a spectacular save to deny Ally Love an injury-time equaliser.
Broomhill travel to Queen of the South in the next round.
Peterhead will host divisional rivals East Fife after coming from behind to see off Dundee Colts. Corey Panter put the Dark Blues ahead but a goal in each half from Niah Payne ensured the Blue Toon would be advancing to the next round.
Ten-man Buckie Thistle triumphed in their all-Highland League clash with Brechin City. Sam Morrison put the Jags in front ten minutes before the interval only for Luc Bollan to restore parity early in the second period.
Sam Urquhart put Buckie back in front and Callum Murray added a third after Morrison had been sent off for the visitors, with Buckie meeting Inverness Caledonian Thistle in round two.