New York Yankees' Starlin Castro tosses his batting helmet as he jogs down the third base line after hitting a walk-off home run against Colorado Rockies relief pitcher Jason Motte (30) during the ninth inning of a baseball game, Wednesday, June 22, 2016, in New York. The Yankees won 9-8. (AP Photo/Julie Jacobson)
New York Yankees' Starlin Castro tosses his batting helmet as he jogs down the third base line after hitting a walk-off home run against Colorado Rockies relief pitcher Jason Motte (30) during the ninth inning of a baseball game, Wednesday, June 22, 2016, in New York. The Yankees won 9-8. (AP Photo/Julie Jacobson)

New York — Starlin Castro hit a game-winning home run to lead off the bottom of the ninth, and the Yankees rallied to beat the Colorado Rockies 9-8 on Wednesday.

New York trailed 8-4 going into the seventh, but Carlos Beltran’s three-run homer helped bail out CC Sabathia after his worst outing of the season.

It was the first career walkoff homer for Castro, who smashed the second pitch he saw from Jason Motte (0-1) to left field.

Sabathia had allowed just four earned runs total over his previous seven starts. He gave up five in 4 innings Wednesday.

Chase Headley also had a second-inning grand slam for the Yankees. Nick Hundley and Ryan Raburn homered for the Rockies.

Mets 4, Royals 3

New York — Matt Reynolds snapped a sixth-inning tie with his first major league home run, leading Noah Syndergaard and New York past Kansas City a two-game sweep in their World Series rematch.

Asdrubal Cabrera homered for the second straight day and scored with an acrobatic slide to help Syndergaard (8-2) win his sixth consecutive decision. The only bad news for banged-up New York was another injury, this one to Yoenis Cespedes.

Astros 3, Angels 2

Houston — Jose Altuve homered and Marwin Gonzalez’s tiebreaking RBI triple in the eighth inning helped Houston to its fifth straight win.

George Springer singled with one out before Gonzalez hit a towering fly ball just to the right of straightaway center field off Matt Shoemaker (3-8).

Cardinals 7, Cubs 2

Chicago — Michael Wacha pitched into the seventh inning for his first win in nearly two months and St. Louis waited out Jake Arrieta before roughing up Chicago’s bullpen in a victory over the Cubs.

Aledmys Diaz hit a two-run home run, and Matt Carpenter had a two-run double in a five-run sixth after Arrieta (11-2) left the game.

Marlins 3, Braves 0

Miami — Adam Conley pitched a career-high eight innings and Miami broke Atlanta’s six-game winning streak.

The Marlins defeated the last-place Braves for only the second time in eight meetings this year, and for the first time in five games in Miami. Justin Bour hit a two-run homer, his 12th.

Blue Jays 5, Diamondbacks 2

Toronto — Russell Martin hit a three-run homer and Edwin Encarnacion and Troy Tulowitzki added solo shots as Toronto snapped the Diamondbacks’ five-game winning streak.

With the win, the Blue Jays earned a split of the two-game interleague series. Arizona came into its fifth-ever game in Toronto on an 8-2 run that featured six consecutive road wins.

Brewers 4, Athletics 2

Oakland, Calif. — Scooter Gennett and Kirk Nieuwenhuis homered to back Junior Guerra’s first victory in more than a month, and the Brewers earned a split of their quick two-game interleague series against Oakland.

Gennett connected on a two-run shot in the fifth and Nieuwenhuis in the eighth.

Orioles 7, Padres 2

Baltimore — Ubaldo Jimenez interrupted his exile to the bullpen with a sharp performance in a starting role, and Baltimore got its 1,000th win at Camden Yards.

Mark Trumbo and Ryan Flaherty homered for the first-place Orioles, who also got two RBIs from Matt Wieters.

Indians 6, Rays 1

Cleveland — Trevor Bauer threw a three-hitter for his second career complete game, Jason Kipnis hit a two-run homer and Cleveland got its sixth straight win.

Bauer (5-2) struck out 10, walked one and allowed only one runner past second base. It was the second straight three-hitter for the Indians, following Corey Kluber’s in a 6-0 win over the Rays on Tuesday.

Giants 7, Pirates 6

Pittsburgh — Buster Posey threw out John Jaso attempting to steal second base to end the game after Joe Panik’s two-run double capped a three-run sixth inning that helped San Francisco rally from an early five-run deficit.

NL West-leading San Francisco has won 11 of its last 13 and scored 73 runs in that stretch.

Rangers 6, Reds 4

Arlington, Texas — Cole Hamels struck out eight in six solid innings, Prince Fielder had a two-run single and Texas got a split in the two-game interleague series.

The Rangers, who have the American League’s best record at 47-26, went ahead to stay with four runs in the fourth off Dan Straily (4-4).

Hamels (8-1) scattered five hits, walked two and allowed only one run.

Tigers 5, Mariners 1

Detroit — Steven Moya homered twice, and Detroit withstood a shaky fifth inning from right-hander Michael Fulmer.

Miguel Cabrera also went deep for Detroit, and reliever Kyle Ryan (2-2) helped the Tigers stay comfortably ahead after Fulmer went through some control problems in the fifth.

Hisashi Iwakuma (6-6) allowed five runs and 11 hits in 4 innings. The Mariners have lost five straight.