Hanrahan left Monday's game against the Minnesota Twins complaining of arm pain. An initial diagnosis of a torn flexor was made, and later confirmed by Andrews.
"As of now, it's just going to be the flexor (surgery)," Hanrahan said. "When he gets in there and takes a look, it could be worse, it could be not as bad."
Hanrahan, 31, finishes the season with just nine appearances for the Red Sox, his first with the club serving as the Pittsburgh Pirates' closer in 2011-12.
He went 0-1 with four saves and a 9.82 ERA for Boston after missing the final two weeks in April with a hamstring strain.
Over his seven-year career with Boston, Pittsburgh and Washington, Hanrahan has compiled a 22-18 mark with 100 saves and a 3.85 ERA in 362 games.