Hahn, who failed to make the cut in his previous eight tournaments and hadn't shot a round in the 60s since February, made a 4-foot putt on the par-4 18th to win his second career PGA Tour title.
Castro's tee shot on the playoff hole found the creek on the left side of the fairway and his third shot landed in a spectator's shoe on the side of the green, leading to a bogey.
Hahn bogeyed the 18th in regulation for a 2-under 70, and Castro had a 71 to finish at 9 under, one shot ahead of Justin Rose (71). Hahn also won the 2015 Northern Trust Open at Riviera.
Both Castro and Hahn had chances to win in regulation. Castro broke a tie when he rolled in a birdie putt from 6 feet on the 15th hole to get to 11 under. But he quickly gave the lead up with bogeys at 16 and 17 on the ''Green Mile,'' the toughest closing holes on the PGA Tour.
That gave Hahn a one-shot lead and a chance to put pressure on Castro on the 18th hole if he made par. But Hahn rolled a 7-foot putt past the hole and took a bogey. Castro, playing with Fowler in the group behind Hahn, got up-and-down from the rough on right side of the fairway on 18 and went on to make a 6-foot par putt to force the playoff.
Like Castro, the 18th hole ultimately proved to be the undoing for McIlroy and Mickelson, too. McIlroy played the 493-yard hole in 4-over par for the week, including a bogey Sunday when his approach shot landed behind a rock on the other the side of the creek that runs along the left side of the hole. Lefty was left to ponder what could have been had it not been for a quadruple-bogey 8 on the hole Saturday.
''I hit a lot of good shots over the weekend, but unfortunately, one bad hole yesterday kind of cost me,'' Mickelson said.
McIlroy had seven birdies in between his bogeys the first and last holes.
''Anytime you walk off the golf course and shoot 66, you can't be too disappointed,'' McIlroy said. ''But I think in the circumstances having a feeling like I had a chance on the back nine to post a number for the guys to at least think about it and I didn't.''
McIlroy also took a gut shot on 15 when failed to hole a birdie putt, prompting him to immediately drop his hands to his knees as he bent over in disbelief. Both players said they were pleased with how they finished and feel good about their games heading into The Players Championship next week.
Fowler talked Saturday about how he feels more prepared to handle the pressure of playing in the final group of Sunday. But he struggled from the start, and his approach shot on the seventh hole that sailed over the water hazard and landed in the backyard by a house typified his control problems. He finished with a double bogey.