Tampa Bay acquired the veteran shortstop from the Marlins more than a month before the trade deadline, saying he's a "Gold Glove-caliber" defender who's also capable of making them better offensively.
The Rays, third in the American League East behind Boston and New York, will most likely make room for Hechavarria at shortstop by shifting Tim Beckham from the position to play second base.
"We certainly feel we have as good a chance as anybody," senior vice president of baseball operations Chaim Bloom said, adding that Hechavarria is a "talented player who's going to help us win."
Outfielder Braxton Lee and pitcher Ethan Clark will go to Miami in the deal.
Hechavarria, 28, signed with the Toronto Blue Jays out of his native Cuba as a free agent in 2010. He is considered an elite defender, and he has a .255 career batting average and a .629 OPS over parts of six big league seasons with the Blue Jays and Marlins.
Hechavarria has been on the disabled list since May 10 because of an oblique injury. He has played nine minor league rehab games in the past 10 days.
The Marlins inserted rookie JT Riddle at shortstop and were looking to shed what remains of Hechavarria's $4.35 million salary this season. St. Louis and Baltimore were among the other clubs to express varying degrees of interest in him.
Marlins president of baseball operations Michael Hill said Riddle will be the everyday shortstop moving forward. Riddle is hitting .230 with three homers and 23 RBIs in his first big league season.
"This is a young player who doesn't rattle, who is comparable to Hech at shortstop, who gives your offense a different dynamic than we got with Hech," Hill said.
Hill said this wasn't a cost-cutting deal.
"I don't think any of it was salary-driven," he said. "Historically, we've had to battle that."
As for whether the Marlins will be sellers as the trade deadline approaches, "our goal continues to be to try to win as many games as possible. That ultimately will dictate which way we go," Hill said.
Lee, a former 12th-round draft pick out of Ole Miss, was hitting .318 for Tampa Bay's Double-A Montgomery farm club this season. Clark, a 15th-round selection in 2015, is 3-2 with a 3.11 ERA for Bowling Green in the Class A Midwest League.
The 22-year-old Clark was 3-2 with a 3.11 ERA in 12 games at Class A Bowling Green.
Information from The Associated Press was used in this report.