Aberdeen beat Rangers 2-1 in the Ladbrokes Premiership at Pittodrie in front of 19,263 fans on Sunday afternoon.
Jonny Hayes gave the Dons the lead less than 30 seconds after the break when he latched on to an Adam Rooney flick and ran clear to beat Wes Foderingham.
Andy Halliday equalised when he converted a 79th-minute penalty after Hayes had brought down Lee Wallace but substitute James Maddison scored a stunning last-minute free-kick to win it for Derek McInnes’ men.
In the day's later game, Hamilton Accies and St Johnstone drew 1-1 at the SuperSeal Stadium. Greg Docherty gave Martin Canning's men a first-half lead but Liam Craig equalised for Saints eight minutes from time.