Duda, 31, is hitting .246 with 17 home runs and 37 RBIs for the Mets, an organization with whom he's spent his entire career.
The Rays are taking on all of Duda's salary, about $2.5 million, according to ESPN's Buster Olney.
The Rays entered Thursday 2½ games behind the first-place Red Sox in the AL East. They're one game behind the Kansas City Royals for the second wild card.
Drew Smith, a right-hander, is going from the Rays to the Mets as part of the deal, according to multiple reports.
Smith, 23, had most recently been pitching for Double-A Montgomery. In appearances for four minor league teams this year, he was a combined 1-2 with a 1.60 ERA and a 0.91 WHIP, with 40 strikeouts in 45 innings.