After conceding early on, an edgy Saints looked set for a third defeat in this competition's final, but Esmael Goncalves' leveller before the break reignited the side sitting just off the foot of the SPL and goals by Steven Thompson and Conor Newton guided them to their first major trophy for 26 years.
It was tough on loser Ryan Stevenson who twice hit the woodwork and whose late second goal in this sizzling contest set up a frantic finale, but the day belonged to the battling team from Paisley.
A delightful chip by Paul McGowan almost gave them the lead (9) but it was Hearts, desperate to add to last year's Scottish Cup success, who dictated for much of the first half and soon got their reward.
After two crunching defensive tackles on the left, the ball fell kindly for Stevenson and the midfielder, banned for the semi-final, turned on the edge of the box before his deflected shot flew past Craig Samson's despairing palms.
The lead was almost doubled with John Sutton's header slamming the right post and with Michael Ngoo and Mehdi Taouil also going close, the Hearts juggernaut kept marauding forward.
The game should have been done and dusted after 36 minutes of one-way traffic, but the contest was blown wide open as St Mirren secured a shock equaliser.
Thompson's pass had Gary Teale through on goal and with keeper MacDonald to beat, the winger selflessly rolled it across for Goncalves to slot in.
The Hearts defence had started to look jittery after the break it was breached again, as Thompson smacked in Paul Dummett's low cross.
Back came Saints as the towering Ngoo, on loan from Liverpool, continued to menace, mis-hitting Taouil's cross from three yards.
Mistakes were on the rise by the tiring sides, but a moment of class had the black and white half of the stadium erupting as St Mirren had a two-goal advantage (66).
Newton burst into the box after a cute one-two with Goncalves and the 21-year-old midfielder, on loan from Newcastle, rifled in the third and his first for the club.
McHattie and Ngoo went close as Hearts fought back and they were handed a lifeline with five minutes left as Stevenson squeezed in his second soon after he saw a shot crash off the bar.
Stevenson again found the woodwork with a rasping drive, but Saints weren't to be denied as their fans celebrated their first silverware since their Scottish Cup final win over Dundee United in 1987 and help erase the memories of losing to nine-man Rangers in the 2010 League Cup final.