A league source told ESPN NFL Insider Adam Schefter that Dumervil's agreement is for five seasons and worth $35 million, including $8.5 million in Year 1.
The star defensive end's agreement with Baltimore was earlier reported by the Denver Post.
Dumervil became a free agent earlier this month after he was released by the Denver Broncos when paperwork for his reworked contract didn't make it back in time to the team. He had agreed to reduce his salary from $12 million to $8 million for next season.
Dumervil took to Twitter to say goodbye to the Broncos.
"Can't say enough about the Broncos fans, my great teammates, equipment staff, training staff, media staff, Mr. Bowlen, Coach Fox, John Elway and the city of Denver," Dumervil tweeted. "Its been an unforgettable 7 years. I am looking fwd to this next chapter of my career."
The Broncos had made other offers to re-sign Dumervil after his release.
"As we have from the start of this process, we worked diligently over the last week to find a way for Elvis Dumervil to remain a Denver Bronco. Although we made multiple contract offers to Elvis after being forced to release him, we were unable to reach an agreement and are now moving forward without him," Broncos executive vice president John Elway said in a statement.
"Elvis was a team captain and a talented player who made a great impact during his seven seasons in Denver. I appreciate all of his effort on the field and the work he did in the community. I wish Elvis all the best as he continues his NFL career," Elway said.
Dumervil signed a six-year, $61.5 million contract in 2010. He had 11 sacks last season, second on the team behind Von Miller. Dumervil led the league with 17 sacks in 2009.
He becomes a welcome addition to the Ravens, who have seen several key contributors to their Super Bowl victory leave this offseason.
Baltimore has released defensive back Bernard Pollard and guard Bobbie Williams, traded wide receiver Anquan Boldin to the 49ers, lost linebackers Dannell Ellerbe and Paul Kruger in free agency and watched linebacker Ray Lewis and center Matt Birk retire. Safety Ed Reed has signed a three year contract with the Texans.
Information from ESPN.com's Bill Williamson was used in this report.