Bastardo gets a $250,000 signing bonus, payable on June 30. The deal announced Friday includes salaries of $5.25 million this year and $6.5 million in 2017.
The 30-year-old Bastardo was 4-1 with a 2.98 ERA and one save in 66 games last season as Pittsbuigh won an NL wild card. He struck out 64 and walked 26 in 57 1-3 innings.
Coming off their first World Series appearance in 15 years, the Mets were looking to reinforce their bullpen after setup man Tyler Clippard became a free agent. Bastardo likely will team with right-hander Addison Reed to set up closer Jeurys Familia.
Bastardo was suspended 50 games by Major League Baseball in 2013 following the Biogenesis drug investigation.
He pitched for division rival Philadelphia from 2009-14 and is 24-19 with a 3.58 ERA and 12 saves in seven major league seasons, holding left-handed hitters to a .178 batting average. While he has struggled with control at times, he has 388 strikeouts in 316 1-3 innings.