Ben Crooks scored four tries for Hull FC but it was not enough to earn victory as Castleford Tigers launched a second-half fightback from 16-6 down.
Rangi Chase was the Tigers star, scoring one of five tries but it was his creative influence with the ball in the second half that proved crucial.
Richard Owen, Daryl Clark, Jonathan Walker and James Clare earned Daryl Powell a win in his first home game.
Kiwi hooker Aaron Heremaia scored Hull's other two scores.
Kirk Dixon was crucial to the win, outkicking rival Daniel Holdsworth with five from five, while the Australian could only land two from six.
Cas lost the return fixture 52-0 in March under former boss Ian Millward, but their character was evident after a first half in which they trailed at the break.
The Airlie Birds were heavily involved in the contest, with Crooks, Tom Lineham and the debutant Jacob Miller impressive, but head coach Peter Gentle will be disappointed to see the match slip through their fingers after a decent first 40.
Jordan Tansey kick almost crept out for a 40-20 for the home side but it was Hull who opened the scoring with a move forged in Castleford stock from the resulting set.
Former Tigers second-row Joe Westerman broke the line with pace, and a measured pass to Crooks - born in nearby Pontefract and the son of Lee Crooks - on his outside put the centre away to score.
Holdsworth converted, but the response was immediate as Owen climbed above Jason Crookes to take in Chase's kick to the right corner to bring Cas level after Dixon slotted the conversion.
Both sides enjoyed spells of possession, but as the half ticked on Hull gained momentum and ended the half the stronger with two scores in the last eight minutes.
The first came as Weller Hauraki was off the field through injury, started and finished by Heremaia and built upon good work from Andy Lynch and Liam Watts, and the second saw Crooks run in after a scrum-base move that was gifted by James Clare's mistake.
Gentle's side looked comfortable at half-time, but Castleford - and in particular Chase - showed their class to set the contest alight in the second period.
Chase showed his class to feed Dixon and then popped on the inside for the return to touchdown, and the England half-back then dropped off to Huby who powered through before slipping short to Clark to pull level.
Dixon's third kick put them in front, and then Chase's 40-20 gave field position which Jonathan Walker made the most of when he spun his way through to crash over.
Heremaia brought Hull back into the game when he dived in on the left, Lineham's wriggling run off the right the catalyst, and after debutant Miller showed pace and a step to gallop clear, Crooks roared in for his hat-trick score.
Both sides continued to contribute to a thriller with play ebbing and flowing, and that was reflected by Castleford's fifth try.
Holdsworth's hanging kick was batted back by Shannon McDonnell as Hull pushed in on the Cas line, but it was the yellow shirted Clark who got to the ball and streaked the length of the field to regain the lead.
Crooks's brave dive in on the right brought Hull back within two, and sparked a late surge but when Lineham was stopped centimetres short on the line, the home side were able to cling on and avenge their earlier season mauling at the KC Stadium.
VIEW FROM THE DRESSING ROOM
Castleford head coach Daryl Powell:
"It was unbelievable to be honest, you didn't know which way it was going to go from start to finish. I'm delighted for the team and delighted for the fans. It was good to see them at home at last.
"I'm obviously pleased to come out as winners but there are certainly some things we need to look at that we need to improve. We're trying to cut down on the number of points we concede but we worked so hard.
"Rangi Chase really got a grip on the game and everybody went with him, and I thought our pack was immense, especially Craig Huby and Grant Millington, but it was a team effort. We responded superbly. We were down by 10 points at half-time but there was nothing in it."
Hull FC head coach Peter Gentle:
"I am disappointed. We didn't give ourselves a chance. We didn't deserve to win the game, we didn't deserve to be that close.
"We are a mile from where we were a month ago. We lacked a bit of composure and defending the way we are puts pressure on you. We have a lot of work to do defensively.
"Jacob [Miller] is going to improve. If our middle are not doing their job, it doesn't matter who we have out there, we're not going to get the result."
Castleford Tigers: Tansey; Owen, Shenton, Dixon, Clare; Hauraki, Chase; Boyle, Milner, Huby, Holmes, Millington, Massey.
Substitutes: Walker, Clark, Thompson, Davies
Hull FC: McDonnell; Lineham, Crooks, Arundel, Crookes; Holdsworth, Miller; O'Meley, Houghton, Green, Whiting, Westerman, Pitts
Substitutes: Galea, Lynch, Watts, Heremaia