Castleford moved a nervous step closer to a return to the Super League, but they nearly stumbled in the last few minutes against a resilient Halifax side.
When Paul Handforth dropped a goal for a 15-2 lead with 15 minutes to play, the Tigers seemed to be cruising to a National League One Grand Final against Whitehaven on Sunday.
But late tries from Ricki Sheriffe and Andy Kirk put them under the sort of pressure that could easily have made them buckle as they were left hanging on grimly for the last seven minutes.
This was a recurring nightmare for Castleford after last week's late defeat by Whitehaven.
"All our supporters were thinking 'here we go again'," said the Cas coach, Dave Woods. "In the last few minutes I was just hoping and praying we could hang on and we did."
This was not a performance to fill Castleford's fans with confidence for the final. They took the lead with two penalties from Richard Fletcher, although Sheriffe and Dean Lawford went close for Halifax.
The visitors got on to the scoreboard through Pat Weisner's kick but Cas claimed the game's first try when Brad Davis darted for the line. The defence managed to stop him but was then slow to react when Michael Platt found a gap on the next tackle. Steve Crouch converted.
Halifax should have narrowed the gap before half-time when their former Castleford full-back, Damian Gibson, made a clean break but threw the ball into touch.
David Larder had a try disallowed at the start of the second half and Halifax seemed to have had their chance when Cas moved the ball crisply to the right for Damien Blanch to score in the corner.
Handforth made it into a 13-point lead, which looked enough until Lawford released Gibson, who kicked ahead for Sheriffe to touch down. Weisner added the goal and five minutes later threw the long pass that allowed Kirk to slide in.
This time Jamie Bloem hit the post with his conversion. The home crowd and players were wilting, but Cas held on.
"We waited too long for our cameo,'' said Halifax's coach Anthony Farrell. "I'm proud of what the boys have achieved this year. We have failed at the last hurdle but we've got a lot of good memories to look back on.''
Castleford: Platt; Pryce, Eagar, Hepworth, Blanch; Davis, Henderson; A Watene, A Smith, Fletcher, Haughey, Crouch, Bird. Substitutes used: Handforth, B Smith, Vowles, F Watene.
Halifax: Gibson; Haley, Kirk, Blackwood, Sheriffe; Lawford, Black; Hobson, Fisher, Boults, Larder, Ball, Weisner. Substitutes used: Bloem, Spink, McDonald, Birchall.
Referee: K Kirkpatrick (Warrington).Reuse content