Ramos, 30, hit .297 with 14 home runs and 53 RBIs in 78 games this season for the Rays. The two-time All-Star hit .260 with 11 home runs and 35 RBIs in 64 games in 2017. He made his first All-Star appearance in 2016, hitting .307 with a career-high 22 home runs and 80 RBIs in 131 games during that campaign.
Ramos has an $8.5 million salary in 2018 and is a free agent in 2019.
The Phillies also acquired left-handed pitcher Aaron Loup on Tuesday in a trade with the Toronto Blue Jays. Philadelphia sent Triple-A pitcher Jacob Waguespack to Toronto in that swap.
Ramos has been out of the Rays' lineup since July 14 due to a left hamstring injury. He was put on the 10-day disabled list because of the ailment, but is expected to return to the lineup in August.
Jorge Alfaro, 25, is hitting .254 with seven home runs and 23 RBIs this year for the Phillies. He has appeared in 78 games this season as the Phillies' primary backstop.