New York is sending a player to be named or cash to Pittsburgh for the 29-year-old Hechavarria, who is batting .254 with four homers and 29 RBIs in 76 games with the Rays and Pirates this season. As part of the deal, the Pirates will send New York $863,709 to cover most of the $951,613 remaining in Hechavarria's $5.9 million salary.
The trade was completed just before Friday's deadline for traded players to be eligible for the postseason. The Yankees are in position for the first AL wild card.
Gregorius has been out since Aug. 20 with a bruised left heel. He could come off the disabled list this weekend.
Hechavarria is a .255 career hitter over seven seasons with four teams. He has played mostly at shortstop with spot duty at second base and third base.
To make room on the 40-man roster, the Yankees designated left-hander Ryan Bollinger for assignment.
More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP-Sports