Ruben Amaro Jr. said he wanted a top closer.

He got one.

The Phillies have reached agreement on a four-year contract with free-agent Jonathan Papelbon, multiple sources told CSNPhilly.com on Friday.

The deal, which won't become official until Papelbon passes a physical in the coming days, is worth $50 million. That is the most ever guaranteed a reliever, topping the $47 million that Toronto gave B.J. Ryan in a five-year deal in Dec. 2005. The average annual value of Papelbon's deal is $12.5 million. That's the same average value of the three-year extension that Brad Lidge signed with the club in 2008.

Papelbon, who turns 31 on Nov. 23, averaged 36 saves for the Boston Red Sox over the last six seasons. He will replace Ryan Madson, a 1998 Phillies' draft pick whose emergence helped the Phils win the 2008 World Series.

Madson, 31, became the Phillies' closer in April and had 32 saves. He could end up replacing Papelbon in Boston. The Texas Rangers and Washington Nationals could also have interest in Madson.

According to sources, Papelbon's deal includes a fifth-year option.

Not long ago, the Phillies were reluctant to give pitchers deals of more than three years. In successive off-seasons, they have made it clear they will relax that policy for the right pitcher. Last year, they gave Cliff Lee a five-year, $120 million deal. The willingness to go four years with Papelbon shows just how much Amaro, the team's general manager, values having a top closer behind his star-studded starting pitching rotation.

"If we don't stop games that we're supposed to win with our staff, then it's going to be troublesome and that is something that we need to shore up," Amaro said of the closer position earlier this week.

Why didn't the Phillies shore it up by re-signing Madson? Phillies officials aren't commenting, but it appears as if they simply thought Papelbon was a better option. The Phils were negotiating with both pitchers earlier in the week. Sources close to Madson said the two sides were making good progress on a four-year deal when the Phillies suddenly expressed reservations about the proposed deal. Phillies officials say no deal was ever struck between them and Madson. During the week, the focus shifted to Papelbon, and that was verified with Friday's agreement.