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 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.

"It gives us a proven playmaker, an outstanding runner, an outstanding receiver and an outstanding pass protector," offensive coordinator Cam Cameron said. "He knows this system and he has played extremely well in this system."

Williams has a history of failed drug tests for marijuana and has been suspended by the NFL previous. He has also retired in the past only to return to football.

He has been diagnosed with borderline personality disorder, which was treated successfully with therapy and medication.

"I think those things are way, way, way in the past," Cameron said. "My relationship, my experience with him, there is no risk, but we're all human. There's risk with everybody. We all make mistakes. Ricky's not perfect, but I know he's got a great heart and he's a great football player."