The clash at the national stadium had looked set to end goalless before the injury-time strike sealed a 10th win in a row for the Irn-Bru Third Division leaders.
Saturday's match - in front of a crowd of 30,117 - was the first Hampden clash between the sides since November 1957, when Rangers came out on top as 4-2 winners.

