NEW YORK — Khris Davis, Matt Chapman, Jed Lowrie and Matt Joyce all homered and the Oakland Athletics beat the Yankees 10-5 Friday night, leaving New York with back-to-back losses for the first time in more than a month.

The A’s had lost three in a row before roughing up Sonny Gray, their former ace. Oakland has won five straight overall against the Yankees.

Marcus Semien drove in four runs for the A’s, three on a double in the ninth inning.

Davis led off the second inning with his 10th home run, driving a fastball into the right-field bleachers. After Matt Olson singled, Chapman hit an 0-2 pitch 429 feet into the loading dock in center for a 3-0 lead.

Gray (2-3) was acquired from Oakland just before last year’s trade deadline for outfielder Dustin Fowler and two minor leaguers. Drafted 18th overall in 2011, Gray was 44-36 with a 3.42 ERA over parts of five seasons with the A’s.

Making his first start in the majors, Fowler lined a single to right in his second at-bat, notching his first big league hit against the player he was traded for. Once a rising star in the Yankees’ system, Fowler suffered a major knee injury while trying to make a catch last June in his debut and was dealt to Oakland a month later.

Gray allowed five runs on nine hits over five innings, walking three.

Aaron Judge hit his 10th homer and rookie Gleyber Torres hit his third for the Yankees.

Recalled from the minors to make the start, Kendall Graveman (1-5) worked quickly and efficiently – needing just 43 pitches to get through the first four innings.

The Athletics’ opening day starter, Graveman was optioned to Triple-A after going 0-5 with an 8.89 ERA. He allowed four runs, only one of them earned, on three hits and two walks over six innings, striking out four.

Blake Treinen got four outs for his sixth save in eight chances.

Lowrie lined a solo shot just inside the right-field foul pole in the sixth off reliever David Hale. Joyce connected against Hale in the eighth.

The loss to the A’s gave New York its first two-game skid since April 10.

ORIOLES 9, RAYS 4: Manny Machado hit two home runs, including his eighth career grand slam, and Baltimore won at home for its season-high third straight victory.

Machado ripped a two-run shot in the first inning and made it 8-1 in the seventh with a drive off Ryne Stanek. Machado has three home runs in his last two games, 12 for the season and 150 over his seven-year career.

Mark Trumbo and rookie Chance Sisco also homered for the Orioles. After a dismal start to the season, Baltimore (11-27) is riding its longest winning streak since a six-game run last August.

NATIONAL LEAGUE

MARLINS 6, BRAVES 3: J.T. Realmuto had three hits, including his fifth homer, and host Miami broke a four-game losing streak.

Realmuto doubled and scored in the first inning, homered in the third and singled home a run in the fourth. Starlin Castro hit his second homer and drove in two runs, and Miguel Rojas had three of Miami’s 14 hits.

Dan Straily (1-0), making his third start after beginning the season on the disabled list, allowed two earned runs in five innings.

METS 3, PHILLIES 1: Michael Conforto hit a two-run homer in the ninth inning off Phillies closer Hector Neris and New York rallied to win at Philadelphia.

Phillies starter Jake Arrieta allowed five hits over 71/3 scoreless innings, and they led 1-0 until Neris allowed a one-out single, Conforto’s third homer and a homer to Devin Mesoraco on the next pitch. It was the second blown save for Neris (1-3) in six days, both costing Arrieta a victory.

Odubel Herrera extended his on-base streak to 40 games with a first-inning home run for the Phillies, who had won four straight.

INTERLEAGUE

CUBS 11, WHITE SOX 2: Willson Contreras had two homers, two doubles and drove in a career-high seven runs on his bobblehead day, and the Cubs pounded the crosstown White Sox at Wrigley Field.

Contreras capped a five-run first against Carson Fulmer with his second career grand slam. He doubled in the fourth, hit a solo homer in the sixth and added a two-run double in the seventh. That gave him three doubles, two triples and two homers in his past 10 at-bats. Contreras is also the first Cubs player with seven extra-base hits in two games since at least 1913, according to STATS.

Kris Bryant homered for the fourth time in five games as the Cubs collected 15 hits.