Auchinleck Talbot claimed a record seventh Scottish Junior Cup win with a narrow but deserved win over Bathgate.
Talbot celebrate their opening goal
Talbot took the lead when Stevie Mallan's 40-yard head flick somehow found its way into the net.
Bathgate drew level when Derek Anderson sent a diving header past his own goalkeeper late in the game.
But the Ayrshire side clinched the victory in the dying minutes when substitute John Boyle sidefooted the ball home with the keeper stranded.
Talbot's first attempt on goal came when Stuart Davidson swung an inviting cross into the Bathgate box, but Mallan's glancing header was off-target.
The breakthrough came in farcical circumstances.
The ball was cleared upfield by Talbot keeper Stuart McIntosh and Mallan leapt well to head the ball on.
However, as the ball bounced through to Ross Godfrey, with Brian Gillies attempting to latch onto Mallan's flick, the keeper slipped and allowed the ball to trundle into the net.
Bathgate came to life immediately, but McIntosh pulled off two tremendous saves within the space of a minute to keep his side in the lead.
Talbot almost doubled their lead shortly after half-time, but Godfrey pulled off a superb save to tip Brian Young's curling free kick round the post.
Godfrey was again alert to push a Brian Slaven drive over the bar and those saves proved vital when Bathgate grabbed an equaliser equally as bizarre as Talbot's opener.
The ball was swung hopefully into the Talbot box, only for Anderson to dive headlong to direct the ball past his own keeper.
But just as the game seemed to be heading for extra-time, Talbot grabbed a late winner.
Mallan caused problems in the Bathgate area and Boyle was on hand to sweep the ball into the net.