The Ravens initially brought in Griffin to throw to free-agent receivers during a tryout last week and were impressed with his workout. After Griffin took a visit to another team, Baltimore then struck a deal with the former Heisman Trophy winner late Tuesday.
"You look at the veteran quarterbacks out there, where we're at right now, I'm pretty excited about this player," coach John Harbaugh said. "I'm really feeling like we got a steal. I really feel that way."
Griffin hasn't played since the 2016 season.
He was the No. 2 pick in the 2012 draft and counted on to be the franchise quarterback for the Washington Redskins. He made the Pro Bowl and All-Rookie team in 2012, but injuries derailed his career.
The Redskins cut him in 2016, and the Browns signed him to a two-year deal. Injuries limited him to five games with the Browns.
With limited cap space, the Ravens have been in the market for an inexpensive veteran passer. Their options dwindled after 22 quarterbacks signed in the first three weeks of free agency.
Other than Flacco, the only quarterback on the roster had been Josh Woodrum, who spent all of last season on the practice squad and has never thrown a regular-season pass. Ryan Mallett, the Ravens' backup the past two seasons, is an unrestricted free agent.
Baltimore had expressed interest in Griffin last summer, when Flacco was sidelined during training camp with a herniated disc. But Griffin was looking for some guarantees before working out with the team last year.
After being out of football last year, Griffin was more receptive in coming to Baltimore.
"I felt like he wanted to be a Raven," Harbaugh said. "He felt like this was the place for him. I believe our players are going to love the fact that he's here. They like him as a person. It makes us a better football team. This moves makes us better."
The addition of Griffin doesn't preclude the Ravens from selecting a quarterback in this month's draft. Team officials have talked about wanting to bring in a young quarterback to groom and raved about the depth of this year's quarterback class.
"If there is a quarterback that feel that we could pick with any of our picks, we'll do it," general manager Ozzie Newsome said.