The Giants are trading their fourth- and sixth-round picks in return for Ogletree and the Rams' 2019 seventh-round pick, the source said. The fourth-round pick is the Giants' second in that round, a compensatory selection.
The trade can't be officially announced until March 14, when the 2018 league year begins.
Ogletree tweeted he can't wait to get to the Big Apple.
The Ogletree trade continued the Rams' theme of opening salary-cap space by parting with players they believe aren't a fit for defensive coordinator Wade Phillips' 3-4 defense, which was also a reason they dealt outside linebacker Robert Quinn to the Miami Dolphins last week.
Ogletree signed a four-year extension with the Rams in October. The deal is worth $42 million, with $33 million coming in the first three years of the deal.
The veteran linebacker will collect a $7 million roster bonus on March 16, the third day of the league year. He will count $10 million against the salary cap this season.
Ogletree will also have his $6 million roster bonus for next year guaranteed by his being on the Giants' roster on March 16.
The Giants were in desperate need of linebackers, especially with their expectation of playing in some 3-4 fronts under new defensive coordinator James Bettcher. Two of the team's three starters at linebacker from last season, Devon Kennard and Jonathan Casillas, are set to become free agents. Only B.J. Goodson returns.
Casillas, the team's defensive captain the past two seasons, is not expected to return. Ogletree should help fill that void.
Ogletree also infuses speed into a Giants defense that struggled badly last season. His ability to cover as a former college safety should also come in handy. The Giants have struggled badly to cover tight ends the past few years. They allowed 12 touchdowns to tight ends this past season, the most in the NFL.
The Rams signed Ogletree to an extension largely because he was a homegrown player they liked. But the deal eventually bought them the flexibility to recoup draft picks through a trade.
The Rams created $5.2 million in 2018 cap space by trading Ogletree and are now approaching $50 million, with about double that cap space in 2019. In the short term, the financial flexibility can be used on the Rams' own free agents -- namely, wide receiver Sammy Watkins and cornerback Trumaine Johnson, whom they have expressed interest in retaining -- and on remaking the defense to fit Phillips' scheme.
Another element is the team's desire to agree on extensions with Aaron Donald, Todd Gurley and Jared Goff, who are each a year apart. The Rams could make Donald the game's highest-paid defensive player this offseason.
Ogletree has compiled 502 tackles, 5.5 sacks, 6 interceptions, 42 passes defended, 12 forced fumbles and 2 touchdowns in 67 games since he was the 30th overall pick out of Georgia in 2013.
His void will come mostly in the locker room, which is why a handful of his Rams teammates have already expressed shock and even frustration through social media. Ogletree served as a captain each of the past two seasons and had developed into the Rams' biggest emotional leader.
ESPN's Jordan Raanan and Alden Gonzalez contributed to this report.