Berwick Rangers needed two extra-time goals to overcome 10-man Third Division Stenhousemuir and progress to the second round of the CIS Insurance Cup.
Scott Gemmill put the Division Two outfit ahead from the spot after Tom Murdock challenged Robbie Horn.
But Willie Lyle drove home the equaliser in the dying seconds.
Scott McCulloch was shown a second yellow card two minutes into extra time and Michael Bolochoweckyj headed home and Garry Wood steered in a third.
Berwick: O'Connor, Manson, McGroarty, Horn, Bolochoweckyj, Fraser (David Greenhill 60), McLeish, Thomson, Gemmill, Wood, McMullan (Swanson 73).
Subs Not Used: Diack, Gary Greenhill, Flockhart.
Goals: Gemmill 15 pen, Bolochoweckyj 105, Wood 111.
Stenhousemuir: Hillcoat, Lyle, McKeown, Tyrrell (Menzies 99), Smith, McCulloch, Thomson (Thom 95), Dempster, Hampshire, Murdoch, John Dillon (McLaughlin 108).
Subs Not Used: Hamilton, Strachan.
Sent Off: McCulloch (92).
Booked: Murdoch, McCulloch, Lyle, McKeown.
Goals: Lyle 90.
Ref: C Brown (Scotland).