The Mets received infield prospect Jeremy Rodriguez in return.
Pham, 35, was batting .268 with 10 home runs, 36 RBIs and 11 stolen bases over 79 games in his first season in New York. He now joins an Arizona team that has dropped out of the National League West lead but remains in the thick of the wild-card race at 57-50. A day earlier, Arizona fortified its bullpen by acquiring closer Paul Sewald from the Seattle Mariners. They've also acquired infielder Jace Peterson from the Oakland Athletics and right-hander Peter Strzelecki from the Milwaukee Brewers.
The Mets, meanwhile, continued to deal players from their 50-55 roster, with Justin Verlander (Houston Astros), Max Scherzer (Texas Rangers), David Robertson (Miami Marlins) and Mark Canha (Milwaukee Brewers) all getting moved in recent days.
The Diamondbacks will be Pham's seventh team after previous career stops with St. Louis, Tampa Bay, San Diego, Cincinnati and Boston.
Pham is a career .260 hitter with 124 homers, 399 RBIs and 108 steals over 955 games.
Rodriguez, 17, has played shortstop for Arizona's Fall league team and batted .256 over 36 games.
Information from Reuters was used in this report.