Martinez provides a right-handed power bat for the Diamondbacks, who sent minor league infielders Dawel Lugo, Sergio Alcantara and Jose King to the Tigers.
"We're real excited because we know what he's capable of,'' Arizona manager Torey Lovullo said. "I've watched him for many years in the American League. He's a special bat. He'll fit right in. Excited to get him in here, get him moving and get started.
"I know the front office has been looking to improve the ballclub. Word came in so late (before Tuesday's game) that this was actually happening."
The 29-year-old Martinez missed nearly the first six weeks of the season after suffering a Lisfranc sprain in his right foot during spring training. He was batting .305 with 16 home runs and 39 RBIs in 57 games.
"I wish we would have come out and been hot and been in first place right now," Martinez said. "And all of a sudden, we're in the playoff hunt here. God has got other plans. That's where he wants me. I've just got to take it for what it is and be excited in joining another good organization in Arizona. I've just got to go out there and help them win."
In his fourth year with Detroit, Martinez clubbed 83 homers in his previous three seasons, establishing career highs with 38 blasts and 102 RBIs in 2015.
"I think any time that you have the ability to acquire a bat that fits in the middle of your lineup, you want to take that opportunity, given where we are and how the season has gone,'' Diamondbacks general manager Mike Hazen said. "He has performed on many different levels in the postseason, with good teams in Detroit. We felt like his presence in the lineup and certainly his ability to hit both sides, to be a good corner outfielder, we felt like it was a good fit for us given where we currently stand."
Said Arizona left-hander Robbie Ray: "My wife texted me that we got J.D. He'll make us that much better. He's got his approach for every pitcher. He uses the whole field."
Martinez batted over .300 in three of four seasons with Detroit after spending his first three major league campaigns with the Houston Astros. He has a .283 batting average with 123 homers and 224 RBIs in 710 games.
"(The Tigers) were the organization that believed in me when everybody else passed," Martinez said. "They were the ones who gave me the opportunity when everybody else didn't. I had a feeling this was coming, this was on the horizon. I wish it could have been different."
Lugo was rated the Diamondbacks' No. 2 overall prospect by Baseball America. The 22-year-old is batting .282 with seven home runs and 43 RBIs in 88 games at Double-A Jacksonville this season.
The switch-hitting Alcantara was batting .279 with three homers and 28 RBIs at Class A Visalia while King, 18, was playing in the Arizona Rookie League.
"It was a very different process for me," Tigers general manager Al Avila said of trading Martinez. "(J.D. and I) were crying. It's very hard. This is not what you plan to do. We all want to win. We want to keep our players. But at some point, it's the best thing for the organization."