New York is seeking stability in a bullpen that has been a mess since the loss of Jeurys Familia, who served a domestic violence suspension at the start of the season and then got hurt. The Mets have blown 13 of 37 save opportunities and rank 26th in the major leagues in bullpen ERA at 4.82.
Ramos, a 30-year-old right-hander, was an All-Star in 2016 and this year is 2-4 with 20 saves and a 3.63 ERA in 40 appearances for the Marlins. Ramos is a proven closer with 92 saves in the past three years and a career ERA of 2.78
He has a $6.55 million salary and is eligible for free agency after the 2018 season.
"Certainly I think the guys ought to be fired up knowing we've got some help coming,'' New York manager Terry Collins said. "A.J. is an outstanding pitcher. Gives us another end of the game guy which is tremendously helpful. The nights whether (Addison Reed) closes or not, we've got another closer down there. That means a lot to us.''
Mets reliever Addison Reed, closing in Familia's absence, is eligible for free agency and has been the subject of trade rumors.
The Marlins' breakup of their bullpen began last week when they traded right-hander David Phelps to Seattle for four prospects, including highly regarded outfielder Brayan Hernandez.
Miami is likely to miss the playoffs for the 14th season in a row, the longest drought in the National League.
"On the heels of Phelps there were probably a half dozen clubs that were still in the reliever market, but ultimately you go where the best players are, and we really like the players we were able to get back for A.J.,'' Marlins' president of baseball operations Michael Hill said. "I think that's ultimately what took us down this path. We're trying to get better and add as much depth and talent to this system and we think we've been able to do that with the deals we've done thus far.''
The Associated Press contributed to this report.