Clayton Kershaw won his 14th game to tie for the National League lead, and the Los Angeles Dodgers beat the Milwaukee Brewers, 5-1, Sunday to avoid a three-game sweep in a matchup of divisional leaders.

Kershaw (14-2) allowed a run and six hits with two walks and six strikeouts in eight innings. He allowed leadoff hitters to reach base in four of the first five innings of an outing that might qualify as a subpar effort for the two-time Cy Young Award winner.

Nevertheless, the left-handed ace lowered his league-leading ERA to 1.78. Adrian Gonzalez drove in two runs, and scored the go-ahead run in the fifth off Jimmy Nelson (2-3).

Ryan Howard had a game-ending single with two outs in the ninth inning after pinch-hitter Marlon Byrd had a tying hit and the Philadelphia Phillies pulled out a victory over the New York Mets.

Chase Utley singled, tripled, homered and drove in three runs for the Phillies, who snapped a five-game skid against the Mets.

Lucas Duda and Travis d’Arnaud homered for New York.

Devin Mesoraco hit his third grand slam of the season and drove in six runs, and the Cincinnati Reds salvaged the finale of a three-game series against the Miami Marlins.

Brad Hand walked Todd Frazier with the bases loaded in the fifth to break a 2-all tie. Mesoraco followed with his second homer of the game and 20th of the season, a 371-foot drive into the left-field seats.

Tyson Ross recovered from a two-run first to pitch six strong innings and Seth Smith hit a bases-loaded triple, leading the San Diego Padres over the Pittsburgh Pirates.

San Diego’s win clinched a 14th consecutive series victory at PNC Park.

Ross (11-10) allowed Gregory Polanco’s two-run shot in the first then shut down the Pirates. He yielded six hits and walked two.

Alex Gordon and Salvador Perez each homered and Danny Duffy pitched into the seventh inning as the Kansas City Royals beat the San Francisco Giants to extend their winning streak to seven games.

The Royals, who won 10 in a row in June, have put together two winning streaks of seven or more games this season for the first time since 1985, the last time they were in the playoffs.

Anthony Rizzo hit a game-ending RBI single in the 12th inning, and the Chicago Cubs beat the Tampa Bay Rays to avoid a three-game sweep.

The last-place Cubs struck out 17 times, running their total to 44 for the weekend series, but Rizzo and touted rookie Javier Baez had two hits apiece to key a 13-hit attack. Carlos Villanueva (5-6) pitched a scoreless inning to earn the victory.

Jose Bautista’s single in the 19th inning drove home the winning run as the Toronto Blue Jays rallied from a 5-0 deficit against Detroit to win the longest game in franchise history.

Munenori Kawasaki singled off Rick Porcello (13-7) to begin the 19th and advanced to third when second baseman Ian Kinsler couldn’t field an errant throw from Porcello on Jose Reyes’ sacrifice bunt. Melky Cabrera was intentionally walked to load the bases for Bautista, who ended it with a single to right over the drawn-in outfield, sending his teammates streaming out of the dugout in celebration.

BALTIMORE — Rookie Kolten Wong had four hits and scored twice, Peter Bourjos homered and the St. Louis Cardinals beat the Baltimore Orioles to avoid a three-game sweep.

After allowing nine home runs in losing the first two games of the series by a collective 22-5 score, the Cardinals amassed a season-high 17 hits — 14 of them singles.

Nick Martinez got his first win since May 24 and Adrian Beltre and Shin-Soo Choo both homered to lead the Texas Rangers to a victory over the Houston Astros, snapping a seven-game skid against their in-state rivals.

Martinez (2-8), who was pitching on five extra days’ rest, allowed five hits and two runs over five innings to end a seven-game losing streak.

Carlos Carrasco rejoined the Cleveland rotation in fine fashion by pitching five dominant innings and the Indians nearly tossed another shutout at Yankee Stadium.

Jacoby Ellsbury homered with two outs in the ninth off Indians closer Cody Allen, ending New York’s season-worst scoreless streak at 19 innings. The shot let the Yankees avoid a dubious distinction — not since 1999 had they been blanked in two straight games, STATS said.

Yoenis Cespedes hit a three-run homer in the eighth inning, Rubby De La Rosa pitched five-hit ball into the eighth and the Boston Red Sox bounced back from a 19-inning loss with a victory over the Los Angeles Angels.

The teams returned just 12 hours after the longest game in the majors this season, a 6 1/2-hour epic won 5-4 by the Angels on Albert Pujols’ homer well after midnight.

Mike Trout homered in the eighth for the Angels (68-49), who still have the majors’ second-best record despite losing five of six.

Kurt Suzuki hit a tiebreaking double and Josh Willingham added two-run homer in the eighth inning, and the Minnesota Twins snapped a 12-game losing streak to Oakland by beating the Athletics.

Brian Dozier connected for his 20th homer in the first before Suzuki and Willingham — both former A’s players — each had a big hit against Luke Gregerson (2-2) in the eighth.