NEW YORK — Sonny Gray outpitched Jacob deGrom, Jacoby Ellsbury and Gary Sanchez homered, and the New York Yankees held off the Mets 5-4 on Tuesday night to sweep both Subway Series games in the Bronx.

Despite another late stumble by closer Aroldis Chapman, the Yankees kept the Empire State Building lit up in pinstripes with the win. The Mets will try to change the color scheme to their shading when the rivalry now shifts to Citi Field for two games beginning Wednesday night.

Gray (7-7) earned his first win in three starts since being traded from Oakland to a playoff contender. He blanked the Mets on four singles until the seventh inning, when he issued a leadoff walk and rookie Dominic Smith followed with his first major league homer.

NATIONALS 3, ANGELS 1: Gio Gonzalez allowed two hits in six scoreless innings, Howie Kendrick hit two solo home runs and host Washington snapped the Angels’ winning streak at six.

Gonzalez (11-5) struck out four and issued three walks. The left-hander, who was three outs from a no-hitter July 31 at Miami, allowed his first hit two outs into the fifth against the Angels.

Kendrick has homered in three of his past four at-bats.

ASTROS 9, DIAMONDBACKS 4: Houston had six extra-base hits in the first four innings, building a big enough lead to hold off the Diamondbacks at Phoenix.

Houston jumped to an 8-0 lead in the fourth inning. Starting pitcher Brad Peacock couldn’t get out of the bottom of the fifth, so Francis Martes (5-2) came on and struck out all four batters he faced in 11/3 innings for the victory.

NATIONAL LEAGUE

GIANTS 9, MARLINS 4: Giancarlo Stanton homered in his sixth consecutive game to give him a major league-leading 44, but Miami fell at home.

Stanton hit a solo shot to deep left-center field off Madison Bumgarner (3-5) in the third inning. He has 11 homers in his last 12 games and 23 in the last 35. Only Sammy Sosa (25 in 1998) and Barry Bonds (24 in 2001) have hit more in that span.

BREWERS 3, PIRATES 1: Keon Broxton hit a pinch-hit home run, Manny Pina drove in two runs, Zach Davies pitched into the seventh and Milwaukee won at home.

AMERICAN LEAGUE

RAYS 6, BLUE JAYS 4: Lucas Duda hit a two-run homer, Wilson Ramos added a solo shot and Tampa Bay won at Toronto to snap a four-game skid.

Backed by Tampa Bay’s biggest offensive outburst since Aug. 1, Blake Snell pitched six innings to win for the first time this season.

INDIANS 8, TWINS 1: Carlos Santana hit two of Cleveland’s five home runs and Danny Salazar continued his strong second-half stretch in the Indians’ rout at Minneapolis.