San Francisco announced the move on Wednesday.
Marsh, 25, was a former fourth round pick by the Seattle Seahawks in the 2014 NFL Draft. The UCLA product had 40 tackles, three sacks, a forced fumble and a fumble recovery in three seasons with the Seahawks. The 6 foot 4, 245 pound defender was traded to New England on Sept. 2. Marsh had 16 tackles, a sack, a forced fumble and blocked a field goal for the Patriots in nine games. He started once this season before being waived on Tuesday.
Marsh had 155 tackles, 25.5 tackles for a loss, 16 sacks, five fumble recoveries and two forced fumbles in 50 collegiate contests for the Bruins.
He could fit in at linebacker or defensive end for the 49ers. San Francisco also claimed defensive tackle Sheldon Day off waivers on Monday from the Jacksonville Jaguars. They cut defensive end Datone Jones on Tuesday.
New England filled Marsh's roster spot with defensive end Eric Lee, who was added from the Buffalo Bills' practice squad.
San Francisco has Leger Douzable, Solomon Thomas, Elvis Dumervil, Aaron Lynch and Ronald Blair III listed at defensive end. The 49ers have Eli Harold, Reuben Foster, Brock Coyle, Dekoda Watson, Elijah Lee, Ray-Ray Armstrong, Pita Taumoepenu and Mark Nzeocha listed at linebacker on their unofficial depth chart.