A masterstroke by coach Kristian Woolf helped turn around a 12-6 half-time deficit and deliver a 26-12 victory as St Helens got their hands on the Challenge Cup after a 13-year absence.
Castleford were on course for their first cup triumph since 1986 after an absorbing first 40 minutes played in front of 40,000 fans at a sun-kissed Wembley, the biggest crowd at a rugby league match for 21 months.
But Woolf sent on Grand Final hero Jack Welsby for the second half in place of tryscorer Theo Fages and he helped transform their fortunes as they scored 20 points without reply to deny Daryl Powell a major trophy in his farewell season in charge of the Tigers.
Both teams lacked composure and precision in the energy-sapping conditions and the plethora of missed tackles would in normal circumstances force a coach to tear his hair out.
But it was a match bursting with passion and intensity – amid plenty of controversy too – as rugby league delivered on its big day out in the capital.
Powell had wrapped his players in cotton wool for the last month, having put all his eggs in the Challenge Cup basket, and the tactic seemed to work as they dominated the first half.
But Saints showed their champion qualities after the break as they made up for their surprise defeat by Warrington two years ago.
In adding the Challenge Cup to their Super League trophy, Wolf has topped the achievement of his predecessor Justin Holbrook, while veteran captain James Roby played a huge role in his club's 13th success.
He collected a fourth winners' medal and was among the second-half tryscorers, 14 years after scoring the first try at the renovated stadium.
The consolation for Castleford was the awarding of the Lance Todd Trophy as man of the match to full-back Niall Evalds, who was on the losing Salford side in 2020.
It began in predictable fashion as Fages, whose gift-wrapped try turned the semi-final Saints' way, made the most of another slice of luck as Jonny Lomax's grubber rebounded off an upright, deceiving defender Olly Holmes, and bounced kindly for the little Frenchman to open the scoring.
Lachlan Coote's conversion made it 6-0 but Castleford demonstrated touches of sheer class to turn the game around.
Evalds started and finished a wonderful move from halfway, regathering the ball from Peter Mata'utia's kick to score an equalising try before stand-off Jake Trueman plucked the ball out of the air following Gareth O'Brien's high kick for the second.
O'Brien converted both tries for a 12-6 lead which could have been greater as the Yorkshiremen dominated the second quarter.
Saints' passing in the sultry conditions became wayward and they were clearly grateful to have the chance to regroup at half-time.
Fages failed to re-appear for the second half and Saints lost second rower Joe Batchelor with a head injury inside the first minute but they soon drew level, albeit in controversial fashion.
Centre Mark Percival was the first to reach Coote's high kick and, after the ball bounced precariously close to the touchline, winger Regan Grace worked it back for Roby to touch down.
Video official Chris Kendall agreed with referee Liam Moore's belief that it was a legitimate try and Coote's conversion tied the scores.
There was no dispute over St Helens' next try, scored in the corner by winger Tommy Makinson after substitute Welsby had cleverly changed the point of attack and that restored the champions' lead.
With the game on a knife-edge, Saints were indebted to a superb tackle to deny his opposite number Evalds and they were forced into more desperate defending after a rare handling error by Roby inside his own half.
But their defence was up to the task and, after rare forays into Castleford territory, Coote made sure their opponents would have to score twice by extending the lead to eight points with two penalties before substitute Kyle Amor plunged over for his first try of the season to clinch the win.