The Marlins will receive center fielder Brayan Hernandez, the Mariners' No. 6 overall prospect, according to MLB.com, and right-handers Brandon Miller, Pablo Lopez and Lucas Schiraldi.
Phelps recorded a 2-4 mark with a 3.45 ERA while notching 51 strikeouts in 47 innings this season. The 30-year-old is in his first season as a full-time reliever after spending the first five years of his career shuffling between the rotation and bullpen.
"David was a target player for us headed into the deadline period," Mariners general manager Jerry Dipoto said. "The quality of his work, particularly over the past two years in the bullpen, in addition to his versatility (including his background as starter) made him very attractive to us. He fits our roster very well and is controllable through the 2018 season."
Phelps is making $4.6 million this season and is slated to be arbitration eligible in 2018.
Phelps owns a 28-32 mark with a 3.90 ERA in 218 career appearances (64 starts) with the New York Yankees and Marlins.
Hernandez has spent most of the year with Short-Season A Everett, batting .252 with two homers and 15 RBIs in 28 games. The 19-year-old Venezuelan earned Dominican Summer League All-Star honors in 2016.
Miller, 22, has posted a 9-4 mark with a 3.65 ERA in 18 starts this season at Single-A Clinton in the Midwest League.
Lopez, 21, owns a 5-8 record with a 5.04 ERA in 19 games at Single-A Modesto in 2017.
Schiraldi has posted a 2-1 mark with three saves and a 4.58 ERA in 28 relief appearances this season for Modesto. He is the son of former major league pitcher Calvin Schiraldi.