Both sides scored eight tries in an end-to-end thriller with Kirk Dixon's kicking proving the difference.
Dixon booted five goals but Widnes could land only three of their eight shots with Patrick Ah Van, Stefan Marsh and Jack Owens all missing efforts.
Gareth Hock scored four tries for the Vikings who were behind 24-8 before fighting back to lead 34-24 until 12 minutes from time.
Castleford then stunned Widnes with Adam Milner, Weller Hauraki and Michael Channing crossing for late tries converted by Dixon.
Tigers star man Rangi Chase and Widnes skipper Kevin Brown were sin-binned after a flare-up 15 minutes from time - and the Tigers then ran in three late touchdowns.
Powell said: "We look like one of the best teams in the league when we are on the front foot but we do get rattled at times.
"It was a crazy game of Rugby League and a real topsy turvy affair.
"It took a big effort from us to get the job done and we scrambled well in the second half.
"It was a game we needed to win and it was a massive effort from Adam Milner to charge down a kick late in the game for Weller Hauraki to score and put us back in front."
Powell also saluted Chase who ran the show in the first half.
"Rangi is a special player but I tend to be on the edge of my seat when he has the ball," said Powell.
"Gareth Hock was in rampaging form for Widnes but it was a big effort from us near the end."
Widnes lost Stefan Marsh with a dislocated shoulder which will rule him out for the rest of the season.
Boss Denis Betts admitted the result encapsulated the story of the season for his side.
He said: "We have worked so hard but then concede more than 40 points.
"This game was the story of our year.
"When we were 10 points up all we needed to do was carry on what we were doing.
"But we crumbled mentally and didn't find any rhythm and they got their tails up.
"Gareth Hock is a world-class player and showed that today but we lacked discipline at times and conceded silly penalties."
Betts refused to blame Brown for his yellow card and added: "If someone throws a punch at you what are you supposed to do? Kevin was only protecting himself."