OWINGS MILLS, Md. -- The Baltimore Ravens have signed veteran running back Ricky Williams to replace Willis McGahee, who they let go days before training camp.

Williams agreed to a two-year deal, the team announced on Monday. The contract is worth $2.5 million with some escalators that could make the contract worth $4 million total, a source told ESPN NFL Insider Adam Schefter.

The former Heisman Trophy played last season with the Miami Dolphins and if everything goes well with his physical on Tuesday, Williams will work in tandem with Ray Rice.

"He's a veteran that brings a lot of leadership," Rice said. "I'm looking to learn a lot from him. I'm looking forward to working with him."

A former Pro Bowler, Williams rushed for a career-high 1,853 yards to lead the league in 2002.

"He's an awesome player," quarterback Joe Flacco said. "He's a legit player."

Last season, Williams, 34, split time with Ronnie Brown in Miami and averaged 4.2 yards per carry. He gained 673 yards and scored two touchdowns.

Williams has rushed for 9,569 career yards and 68 touchdowns, recording 325 receptions for 2,523 yards and eight touchdowns.