NEW YORK — Masahiro Tanaka pitched like the ace the Yankees needed him to be, allowing four hits over seven innings to lead New York over the Toronto Blue Jays 5-0 Sunday and stop his team’s five-game losing streak.

Dustin Ackley homered and had three RBI for the Yankees, who closed back within 3 1/2 games of the AL East-leading Blue Jays with 20 games left.

Toronto had won the first three games of the four-game series, but the Yankees sent R.A. Dickey (10-11) to his first loss since before the All-Star break.

Tanaka (12-6) struck out seven, walked none and threw 76 of 108 pitches for strikes. He is 3-0 with a 2.54 ERA in his last four starts.

TWINS 7, WHITE SOX 0: Torii Hunter hit a three-run homer and an RBI single, Kyle Gibson won for the first time in four starts against Chicago and Minnesota beat Chris Sale in Chicago.

ASTROS 5, ANGELS 3: Pinch-hitter Jed Lowrie hit a three-run homer to complete an astounding five-run rally off Huston Street with two outs in the ninth inning, and Houston stunned Los Angeles in Anaheim, California.

RANGERS 12, ATHLETICS 4: Adrian Beltre homered twice to drive in five runs, Shin-Soo Choo also went deep and Texas beat visiting Oakland to keep pace in the AL West.

TIGERS, INDIANS SPLIT: J.D. Martinez drove in three runs, and Detroit scored four times in the fourth inning to defeat Cleveland 9-2 in Game 2 of a doubleheader in Cleveland.

The Indians won the first game, 7-2.

ORIOLES 8, ROYALS 2: Chris Davis hit his league-leading 42nd home run, Jonathan Schoop added a pair of solo shots and Baltimore took the three-game series against Kansas City with a victory in Baltimore.

NATIONAL LEAGUE

METS 10, BRAVES 7: Daniel Murphy hit a tying three-run homer in the ninth inning, Kirk Nieuwenhuis scored the tiebreaking run on a throwing error in the 10th and New York won its seventh straight game with a victory in Atlanta.

DODGERS 4, DIAMONDBACKS 3: Zack Greinke pitched eight scoreless innings to lower his major league-leading ERA to 1.61 and help Los Angeles win in Phoenix.

PHILLIES 7, CUBS 4: Ryan Howard homered and drove in three runs to help Philadelphia win at home.

PIRATES 7, BREWERS 6: Josh Harrison hit a winning single in the 11th inning, and Pittsburgh rallied from a five-run deficit at home to beat Milwaukee and remain 2½ games behind St. Louis in the NL Central.

CARDINALS 9, REDS 2: Tommy Pham hit a tiebreaking, two-run homer in the sixth inning, pinch-hitter Matt Adams added a two-run drive in a five-run eighth and St. Louis rallied to beat host Cincinnati and avoid getting swept in the four-game series.

NATIONALS 5, MARLINS 0: Max Scherzer pitched eight stellar innings to help Washington end a five-game losing streak with a win in Miami.

GIANTS 10, PADRES 3: Mike Leake pitched six strong innings and hit a three-run homer to help host San Francisco complete a three-game sweep with a win over San Diego.

INTERLEAGUE

ROCKIES 3, MARINERS 2: Nolan Arenado hit a sacrifice fly for his 110th RBI of the season, Colorado scored a pair of runs on Kyle Seager’s throwing error and the Rockies won in Seattle.