Hanie is in Baltimore today and will immediately join the Ravens' offseason conditioning program.
The Ravens later announced the deal.
In Hanie, the Ravens have added another quarterback for training camp and provided Tyrod Taylor with competition for the backup job.
"He's a talented guy," Ravens coach John Harbaugh said. "He's played in games and maybe hasn't been in the ideal situation for him yet. Based on the evaluation of our pro personnel department and our coaches, they felt like he fit us pretty well. If he fits the bill, he can be our third quarterback."
In the three previous seasons with the Bears, he played in 11 games, completing 59 of 116 passes for three touchdowns and 10 interceptions.
His most memorable appearance came in the 2010 playoffs when starter Jay Cutler (knee) and his primary backup Todd Collins (shoulder) were both injured in the NFC championship game against the Green Bay Packers. Hanie came in and led the Bears on two touchdown drives, but he also threw two interceptions, including one that was returned for a touchdown. Hanie finished the game 13-for-20 for 153 yards, one touchdown and two interceptions in Chicago’s 21-14 loss.
He then started four games in 2011 when Cutler went down with a thumb injury in Week 11. The Bears lost all four games and Hanie was ultimately replaced by Josh McCown.
Hanie will be in a similar situation that Curtis Painter was in during last year's training camp. The Ravens signed Painter, a former starter with the Indianapolis Colts, to provide competition for Taylor and to make sure the team had enough quarterbacks to get through the preseason and all the training camp workouts. Painter was released after the final preseason game as coach John Harbaugh opted to go with only two quarterbacks on the roster for the second consecutive season.
Super Bowl XLVII Most Valuable Player Joe Flacco has started every game in his five-year NFL career. Taylor, a former sixth-round pick out of Virginia Tech, has played in 10 games over two seasons, throwing a total of 30 passes with zero touchdowns and one interception.
Team officials have said repeatedly that they are comfortable with Taylor in the backup role.