The Yankees acquired Adeiny Hechavarria in a trade with the Pirates on Friday night, bringing in a veteran infielder to back up injured shortstop Didi Gregorius.

The Yankees are 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 the Yankees $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.

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.