Pittsburgh sent minor league right-hander Matt Seelinger to Tampa Bay for Hechavarria, who was designated for assignment last week.
Hechavarria, 29, is hitting .258 with three homers and 26 RBIs but had lost his role as the Rays' starting shortstop to rookie Willy Adames.
Jordy Mercer is the Pirates' starting shortstop. It wasn't immediately clear how the Pirates plan to use Hechavarria.
Hechavarria was a Gold Glove finalist in both 2014 and '15 when he played for the Miami Marlins. He has 35 triples since the 2013 season.
Seelinger, 23, is 1-3 with a 3.03 ERA in 28 appearances for Class A West Virginia this season.