St Johnstone booked a place in the quarter-finalsĀ of the Betfred Cup after coming from behind to secure victory in a five-goal thriller at McDiarmid Park.
Tommy Wrightās home side looked to be in command of the tie leading 1-0 thanks to an early Danny Swanson screamer but they were stunned as the half drew to a conclusion with Hearts netting a quickfire double from Callum Paterson and Jamie Walker.
Swanson then equalised for Saints in the second 45 with substitute Brad McKay sealing the incredible comeback late on.
Wright made three changes from the side that drew with Aberdeen in Sundayās Premiership opener with Paul Paton, David Wotherspoon and Chris Kane coming in for Steven MacLean, who dropped to the bench, while injured Murray Davidson and Graham Cummins missed out altogether.
Hearts who were beaten later that same afternoon, welcomed back their captain Alim Ozturk with former Dundee United players Prince Buaben and Robbie Muirhead also starting.
The home side had a huge let-off in just the seventh minute when Hearts Conor Sammon capitalised on a Saints mistake before brushing past Tam Scobbie and crashing a low 20-yard shot off Alan Mannusās right-hand post.
However, having survived that scare, St Johnstone took the lead just three minutes later with a goal of the highest quality.
Saints were awarded a free-kick wide right and with Hearts expecting the ball to be pumped into their box, Liam Craig instead squared it to Swanson who sent a sublime, high curling effort from 30 yards that clipped the underside of the crossbar and into the net past the helpless Jack Hamilton in the Jambos goal.
After that frenetic opening spell, the game settled down with both sides probing but failing to carve out further clear-cut openings.
However, Saints did create a chance out of nothing in the 33rd minute with Blair Alston trying his luck with another 30-yard curler but this time Hamilton palmed his effort away to safety.
His opposite number Mannus was helpless though to prevent the equaliser in the 43rd minute.
The keeper had made a good save from a Robbie Muirhead free-kick but Igor Rossi then sent a cross back into the box with Paterson bulleting a header home.
With the game entering stoppage time, Saints would have been hoping to get down the tunnel to regroup but instead they suddenly found themselves facing a 2-1 deficit.
Paterson collided with Scobbie in the box and referee Crawford Allan pointed to the spot to the utter disbelief of the Saints players and their manager. Walker then stepped up to calmly slot the penalty home and turn the game on its head.
St Johnstone came out in determined mood at the start of the second 45 with Brian Easton going close with a long-range shot and then Swanson played a smart corner to Craig whose snap shot was tipped over by Hamilton.
And their pressure finally paid off in the 75th minute when Swanson surged into the Hearts box and was tripped by Ozturk with Mr Allan again pointing to the spot. Swanson dusted himself down to take the penalty and calmly send Hamilton the wrong way to bring Saints level.
St Johnstone tails were up and they completed their incredible comeback in the 80th minute when that man Swanson sent a corner in from the right with McKay running in to send a powerful header past Hamilton to seal a memorable victory.
Attendance ā 4,214.
St Johnstone ā Mannus, Scobbie (McKay, 45), Alston, Anderson, Wotherspoon, Swanson, Shaughnessy, Paton, Easton, Kane, Craig (MacLean, 67).
Subs not used ā Clark, Millar, Coulson, Hurst, Comrie.
Hearts ā Hamilton, Paterson, Rossi, Ozturk, Walker (Watt, 62), Buaben (Smith, 83), Djoum, Souttar, Cowie, Sammon, Muirhead (Nicholson, 62).
Subs not used ā Noring, Oshaniwa, Nowak, Zanatta.
Referee ā Crawford Allan.