The Ravens will receive 2015 fourth- and fifth-round picks from the Lions for Ngata and a seventh-round selection this year, sources said.
"Haloti is a great player but an even better person," Baltimore coach John Harbaugh said. "He has been an anchor of our success for many years. We appreciate everything he has done for our organization and the Baltimore community. We wish he and his family nothing but the best."
Ngata, who had 32 tackles, two sacks and two interceptions last season, has prior experience with Detroit's coaching staff. He played for Lions defensive coordinator Teryl Austin during his time with the Ravens.
"He consistently dominates week in and week out. We're just getting a great player to fill that void of Suh," Lions safety James Ihedigbo, who played with Ngata in Baltimore, said Tuesday. "You talk about Suh being one of those once-in-a-lifetime players in the NFL, you can put Haloti in that list, you know."
Trading for Ngata, who is in the final year of his contract, might seem like an odd fit for Detroit since the Lions had run a 4-3 defense. But with the team's top four defensive tackles set for free agency, receiving Ngata might be a hint the team will switch to a 3-4.
Ngata has played in 135 games and made 446 tackles with 25.5 sacks since being drafted by the Ravens with the No. 12 pick out of Oregon in 2006. The Ravens free up $8.5 million of cap space in the trade. Ngata had a team-high $16 million cap figure.
His cap hit with the Lions will be $8.5 million.
Baltimore was attempting to sign Ngata to an extension, but the sides were never close to a deal.
The 31-year-old Ngata is a five-time Pro Bowler who had been the foundation for the Ravens' run defense. He had his best season in recent memory last year before getting suspended four games for violating the league's policy on performance-enhancing drugs.
"Haloti has been an outstanding player for us for many years," Ravens general manager Ozzie Newsome said. "He consistently showed tremendous leadership in our locker room and on the field. At times, he was one of the NFL's most dominant players."
ESPN Ravens reporter Jamison Hensley contributed to this report.