A thunderbolt from Ryan Jack after 94 minutes in after extra time, before fellow substitute Scott Wright fired in a second – three minutes later – took the trophy back to Ibrox for the first time since 2009.
We look at how the cup was won and some of the pictures that tell the story of the game.
. Rangers goalkeeper Allan McGregor (centre) lifts the Scottish Cup
Rangers goalkeeper Allan McGregor (centre) lifts the Scottish Cup whilst his team-mates celebrate after the final whistle of the Scottish Cup final at Hampden Park, Glasgow. Photo: Steve Welsh
. Hearts prior to kick-off of the Scottish Cup final at Hampden Park, Glasgow
Hearts goalkeeper Craig Gordon (left) lines up with his team-mates prior to kick-off of the Scottish Cup final at Hampden Park, Photo: Steve Welsh
. Rangers warm up ahead of the Scottish Cup final
Rangers’ Kemar Roofe (centre) warms up ahead of the Scottish Cup final at Hampden Park Photo: Andrew Milligan
. Hearts goalkeeper Craig Gordon in action (centre) during the Scottish Cup final at Hampden Park,
Hearts goalkeeper Craig Gordon in action (centre) during the Scottish Cup final at Hampden Park, Glasgow. Photo: Steve Welsh
. Hearts manager Robbie Neilson gestures on the touchline
Hearts manager Robbie Neilson gestures on the touchline during the Scottish Cup final at Hampden Park Photo: Steve Welsh
. Rangers' Calvin Bassey (right) and Hearts' Stephen Kingsley battle for the ball
Rangers' Calvin Bassey (right) and Hearts' Stephen Kingsley battle for the ball during the Scottish Cup final Photo: Steve Welsh
. Rangers' James Tavernier (right) gestures during the Scottish Cup final
Rangers' James Tavernier (right) gestures during the Scottish Cup final. Both sides were at a stalemate in the first half. Photo: Steve Welsh
. Rangers' goalkeeper Jon McLaughlin (centre) in action during the Scottish Cup final at Hampden Park, Glasgow
Rangers' goalkeeper Jon McLaughlin (centre) in action during the Scottish Cup final at Hampden Park, Glasgow. Photo: Steve Welsh
1. Hearts prior to kick-off of the Scottish Cup final at Hampden Park, Glasgow
Hearts goalkeeper Craig Gordon (left) lines up with his team-mates prior to kick-off of the Scottish Cup final at Hampden Park, Photo: Steve Welsh
2. Rangers warm up ahead of the Scottish Cup final
Rangers’ Kemar Roofe (centre) warms up ahead of the Scottish Cup final at Hampden Park Photo: Andrew Milligan
3. Hearts goalkeeper Craig Gordon in action (centre) during the Scottish Cup final at Hampden Park,
Hearts goalkeeper Craig Gordon in action (centre) during the Scottish Cup final at Hampden Park, Glasgow. Photo: Steve Welsh
4. Hearts manager Robbie Neilson gestures on the touchline
Hearts manager Robbie Neilson gestures on the touchline during the Scottish Cup final at Hampden Park Photo: Steve Welsh