Ramirez and left-handed relief pitcher Randy Choate were sent to the Dodgers while the Marlins will receive right-handed pitchers Nathan Eovaldi and Scott McGough, both 22.
Ramirez, 26, is a three-time All-Star, but is hitting .246 with 14 home runs and 48 runs batted in this season while playing third base. He's expected to return to shortstop, his position before this season, in Los Angeles.
He was voted the Rookie of the Year in 2006 and won the National League batting title by hitting .342 in 2009. He's a career .300 hitter with 148 home runs and 481 RBI in eight seasons.
"The addition of a hitter the caliber of Hanley Ramirez improves our lineup from top to bottom, inserting a proven run producer to go along with Matt (Kemp) and Andre (Ethier)," said Dodgers General Manager Ned Colletti. "We're excited for Hanley to begin a new chapter in Los Angeles."
Choate, 36, has played for four teams in a 12-year career. He's 11-11 lifetime with a 4.01 earned run average. He's appeared in 44 games for Miami this year and has a 0-0 record and 2.42 ERA.
Eovaldi is 1-6 with a 4.15 ERA in 10 starts for the Dodgers this year while McGough has been pitching in Single-A Rancho Cucamonga.
Celebrity Families of 2014 [PHOTOS]