BALTIMORE -- After twice reaching outside the organization to enhance their wide receiving corps, the Baltimore Ravens secured one of their own Wednesday night: two-time Pro Bowl player Derrick Mason.

Mason, an unrestricted free agent, agreed to a two-year deal with the team he joined in 2005.

It's a two-year, $8 million deal that includes $3.5 million in the first year, a league source told ESPN NFL Insider Adam Schefter.

Mason's future with the Ravens appeared unclear after they obtained free agent wideout Donte' Stallworth and traded for Anquan Boldin. Mason hinted after the 2009 season that he might retire, and there also was a chance he would sign with another team.

But now he's set to end his career with Baltimore, and his return assures third-year quarterback Joe Flacco a familiar target to go with Stallworth and Boldin.

"This is outstanding, just great news for the Ravens," coach John Harbaugh said. "Our coaches are happy. Derrick's teammates are happy and you know Joe is smiling. ... We would have lost something special if Derrick had gone to another team. We have gotten better in the last couple of days."

The announcement comes just two days after Boldin signed a four-year contract with Baltimore. Boldin had 84 catches for 1,024 yards and four touchdowns last season with Arizona.

The 36-year-old Mason had 73 receptions for 1,028 yards and seven touchdowns in 2009. He started all 16 games and became the 23rd player in NFL history with 800 career catches.

Before the season, he announced his retirement and then returned during training camp. Then, after the Ravens were eliminated in the playoffs by Indianapolis, Mason indicated he would again consider ending his career.