Related Content

In a separate trade, Pittsburgh acquired right-handed starter Ivan Nova from the Yankees for two players to be named later.

The deals were announced shortly after Major League Baseball's 4 p.m. trade deadline.

Niese, 29, was 8-6 with a 4.91 ERA in 23 games with the Pirates, including 18 starts before a bullpen demotion. He is making $9 million in the final year of a contract that includes a $10 million team option for 2017 with a $500,000 buyout.

Nova, 29, was inconsistent for the Yankees this year, going 7-6 with a 4.90 ERA in 15 starts and six relief appearances. He underwent Tommy John surgery in 2014.

Bastardo, 30, agreed to a $12 million, two-year deal with the Mets in January after spending the 2015 season with Pittsburgh. He has a 4.74 ERA and 46 strikeouts in 41 appearances this year. He is owed $6.5 million in 2017.