BALTIMORE — Greg Bird hit his first career grand slam to back a dominant pitching performance by Sonny Gray, and the New York Yankees beat the Baltimore Orioles 9-0 Wednesday night for a split of their four-game series.

Rookie Tyler Wade and Austin Romine also homered for the Yankees, and Giancarlo Stanton had four hits.

Facing Dylan Bundy (6-9) in the third inning, Bird launched a drive off the right-field foul pole to put New York up 5-0. It was the second night in a row he homered and had four RBI.

Gray (6-7) allowed three hits, walked one and struck out eight over six innings. The right-hander had lost three straight starts, giving up 11 runs over 41/3 innings in the past two.

Facing the last-place Orioles couldn’t have come at a better time for Gray. He’s 3-0 with a 2.00 ERA against Baltimore and 3-7 with a 6.32 ERA against everyone else.

The victory enabled New York to improve to 5-5 against the Orioles this season. In this series, Baltimore won 5-4 and 6-5, and the Yankees’ wins were by a total of 17 runs.

In the pivotal third inning, Stanton singled in a run before Bird ended a nine-pitch at-bat by pulling a curveball down the line.

Wade went deep in the sixth, and Romine connected in the seventh. Wade’s long ball, his first in the big leagues, came on his 100th at-bat.

New York has 154 home runs this season, a major league record before the All-Star break. The Yankees have played 91 games; the 1999 Seattle Mariners hit 151 in 87 games.

RAYS 4, TIGERS 2: C.J. Cron’s three-run home run in the seventh inning carried host Tampa Bay to its fifth straight win.

Cron’s 18th homer came off Jordan Zimmermann after singles by Kevin Kiermaier and Matt Duffy.

Cron and Kiermaier each had three hits for the Rays, who have won 14 of 18. It was only the second multi-hit game of the season for Kiermaier, who drove in the game’s first run with his second homer of the season in the third inning.

James McCann’s two-run homer off Matt Andriese in the fourth had given Detroit a 2-1 lead that lasted until Cron’s homer. It was McCann’s sixth homer of the season.

TWINS 8, ROYALS 5: Brian Dozier hit a two-run home run, going deep for the second straight game to give Minnesota a boost in its victory at home.

Lance Lynn (7-7) recovered from a three-run homer by Salvador Perez in the first inning to win his second straight start for the Twins, who used the bottom third of their lineup to launch rallies in the second and the fourth against Royals starter Burch Smith (0-1).

Max Kepler, Jake Cave and Bobby Wilson went 6 for 11 with five runs scored.

Mike Moustakas homered twice for the Royals.

NATIONAL LEAGUE

PIRATES 2, NATIONALS 0: Starling Marte hit a two-run home run and Trevor Williams combined with four relievers on a five-hitter as Pittsburgh beat visiting Washington.

Marte homered to center field with two outs in the third off Gio Gonzalez after Jordy Mercer led off the inning with the first of his two doubles. That was enough to give the Pirates just their third win in nine games.

Williams (7-7) won for just the second time in his past 10 starts, giving up four hits with three strikeouts and three walks. He is 2-5 with a 6.26 ERA in that span after going 5-2 with a 2.72 ERA in his first nine outings.

GIANTS 5, CUBS 4: Buster Posey singled off the right-field wall in the 13th inning for his fifth career game-ending hit, sending host San Francisco past Chicago.

Brandon Belt drew a two-out walk from James Norwood (0-1). Andrew McCutchen then singled to bring up Posey, who ended the 4-hour, 30-minute game with San Francisco’s first run since scoring four in the first.

Dereck Rodriguez (4-1) pitched three scoreless innings for the win. He also had three of San Francisco’s 16 strikeouts.

Norwood worked the 12th and 13th in his major league debut. He immediately struck out Brandon Crawford on a 99 mph fastball.

Cubs slugger Kris Bryant hit a two-run homer in his return from the disabled list, and All-Star Javier Baez tied the game with a solo homer to start the seventh.