Bastardo was signed by the Philadelphia Phillies in 2007 and assigned to the Lakewood BlueClaws of the "Low A" South Atlantic League. In Lakewood, Bastardo went 9–0, with a 1.87 earned run average in 15 games, all of which he started. He had 98 strikeouts and 42 walks in 91.2 innings of work. At the end of the 2007 season, Bastardo was promoted to the Clearwater Threshers of the "High A" Florida State League. For the Threshers in 2007, Bastardo appeared in one game, in which he gave up four earned runs but struck out twelve in five innings.
2008
Bastardo began the 2008 season in Clearwater, where he went 2–0 with a 1.17 earned run average and struck out 47 batters in his 30.2 innings of work. He was then called up to the Reading Phillies of the Double-A Eastern League. In Reading, Bastardo went 2–5 with a 3.76 earned run average in 14 starts. He pitched 67 innings, striking out 62, walking 37, and allowing 56 hits.
2009
Before the 2009 season, Bastardo was converted from a starting pitcher to a relief pitcher, but was converted right back to a starter after only a handful of outings. Phillies pitching coachRich Dubee said that Bastardo had a chance to be in the major leagues at some point in 2009. He was also invited to the Phillies' training camp as a non-roster invitee but was sent to minor league camp on March 16, 2009. After he was sent down, Bastardo joined the Lehigh Valley IronPigs for the rest of spring training before being sent down to the Reading Phillies. Baseball America ranked him as the 11th-best prospect in the Phillies organization in 2009. After posting a 2–2 record, 1.82 ERA in nine games, Bastardo was called up to the Lehigh Valley IronPigs. On May 30, 2009, the Phillies announced that Bastardo would make his major league debut in a start at San Diego on Tuesday, June 2.
2009
After Brett Myers tore his labrum and placed on the 15-day disabled list, the Philadelphia Phillies called up Bastardo on June 2, 2009. He won in his first start against the Padres, allowing only one earned run during his six innings pitched. After his Phillies' debut, Bastardo recorded a 2–3 record with a 6.75 ERA and 19 strikeouts. On June 25, during a start against the Tampa Bay Rays he suffered a shoulder injury that forced him to go on the disabled list. He returned to the Phillies roster for the postseason, where he made a relief appearance in the second game of the National League Division Series against the Colorado Rockies, striking out Jason Giambi with two outs and the bases loaded.
2010
For the 2010 season, Bastardo was converted into a full-time relief pitcher. He was placed on the 15-day disabled list on June 17, 2010. For the season, he recorded two wins and no losses, and an ERA of 4.34.
2011
On April 24, Bastardo earned his first save in the major leagues when he relieved Roy Halladay after innings, inducing one San Diego Padres batter to pop out and completing the game. Bastardo was chosen as interim closer for the Phillies when Ryan Madson went on the disabled list. Bastardo once pitched a 17-inning scoreless streak, lowering his ERA to 0.78 in the process. He would finish the season with a 6-1 record and a 2.64 ERA. On November 14, 2011, it was announced that Bastardo had agreed to let Jonathan Papelbon wear Bastardo's former number 58. Bastardo would end up wearing number 37.
2012
In 2012, Bastardo posted a win-loss record of 2-5 and an ERA of 4.33. Following the season, Bastardo changed his number again, this time to 59, so relief pitcher Mike Adams could wear his number 37.
2013
On August 5, 2013, Bastardo was suspended 50 games by Major League Baseball as part of the Biogenesis baseball scandal. At the time of his suspension, which kept him out for the remainder of the season, he was 3–2 with an ERA of 2.32.
2014
Coming off part of a season during which he was one of the Phillies most "reliable" relief pitchers, Bastardo sought to stabilize the bullpen in 2014 for the Phillies. He recorded an ERA of 3.94 in 67 games.
Pittsburgh Pirates
On December 10, 2014, the Phillies traded Bastardo to the Pittsburgh Pirates in exchange for Joely Rodríguez. Bastardo appeared in 66 games for the Pirates in 2015, recording a win-loss record of 4–1, one save, and an ERA of 2.91.
On January 22, 2016, Bastardo signed a 2-year, $12 million contract with the New York Mets. In 41 games with the Mets, Bastardo recorded an ERA of 4.74. He shared the major league lead in balks, with four.
Return to Pittsburgh
On August 1, 2016, the Mets traded Bastardo back to the Pirates for Jon Niese. He made his Pirates return debut on August 2. Bastardo spent 2 months on the disabled list in 2017 with a quad strain. He was ineffective in his 9 appearances for the Pirates, sporting an ERA of 15.00. He was designated for assignment on July 8, 2017, and released on July 13.
Arizona Diamondbacks
On January 23, 2018, the Diamondbacks signed Bastardo to a minor league deal. He was released on March 20. On July 21, 2018, Bastardo was suspended 140 games for testing positive for the performance-enhancing drug stanozolol.