After an eight goal thriller that earned Hearts a Scottish Cup replay, they travelled to Glasgow to face the University side with a place in the fifth round at stake.
Straight from the whistle Cupar were determined and took the play to the home side.
On 11 minutes Gary Sutherland latched onto a goal kick and squared to Lee Sibanda who should have done better in front of goal leaving Ben Fulton with an easy save.
A foul on Sibanda by Neil Moffat wide left nearly gave Hearts the opener when the free kick was initially cleared but found its way back in to Scott McInroy only for the referee to blow for offside.
The game changed when Hearts made two substitutions early in the second half.
Morgan Dow replaced Gary Sutherland and then Lee Sibanda made way for Jakub Dobes and it was the two substitutes that opened the scoring.
A great run by Ryan Gray found Jakub Dobes who did well to win a corner.
Dobes’ cross was cleared only as far as Morgan Dow who composed himself and picked his spot.
The visitors extended their lead after Jakub Dobes once again won a corner kick.
It was headed goalwards by Scott McKay and Ben Fulton did well to punch clear.
Cupar quickly regained possession and sent the ball back in for Scott McKay to fire in a spectacular volley with 12 minutes remaining.
Cupar were disappointed not to keep a clean sheet when a silly foul gave Glasgow a free kick on the edge of the box and Neil Moffat scored.
Cupar will host East Linton in the fifth Round on January 7 2017.
On Saturday Cupar Hearts host St Monans Swallows in the second round of the Fife Cup at the Duffus Park.
Kick off - 1.30PM.
Cupar Hearts - Cichowski, McLuckie, Murdoch, McInroy, Blyth, Brown, Gray, Wainwright, Sutherland, McKay and Sibanda.
Subs - Inglis, Dow, Brown, Leadbetter, Lawlor, Dobes.