Carp sent a drive over the center-field fence on the first pitch from Roberto Hernandez. It was the first pinch-hit grand slam for Boston since Kevin Millar hit one at Milwaukee on June 7, 2003.

Dustin Pedroia opened the 10th with a walk against Joel Peralta (2-7) and went to second on Shane Victorino’s bunt. After David Ortiz was intentionally walked, Hernandez replaced Peralta and walked Mike Napoli on four pitches before Carp connected for his ninth homer.

Boston closer Koji Uehara (4-0) struck out two during a perfect ninth. He has retired his last 34 batters.

James Loney homered for the Rays, who trail the Red Sox by 9 1/2 games in the division race, to tie it in the eighth. Tampa Bay, which has lost 13 of 17, saw its lead drop to one game over New York for the second AL wild-card spot.

YANKEES 5, ORIOLES 4

BALTIMORE (AP) — Robinson Cano hit a tiebreaking homer leading off the ninth inning, and New York also got solo shots from Alex Rodriguez and Curtis Granderson.

The Yankees moved past Baltimore and Cleveland in the AL wild-card hunt. New York has hit eight home runs in winning two of three in the four-game series that concludes Thursday night.

The Yankees trailed 3-1 before Granderson homered in the fifth — New York’s first hit — and Rodriguez tied it in the sixth with his 653rd career home run.

In the ninth, after Cano connected off Tommy Hunter (4-4), Granderson tripled with one out and scored on an infield hit by Lyle Overbay.

David Robertson (5-1) worked the eighth and Mariano Rivera gave up a run-scoring single to Brian Roberts before securing his 43rd save, tied for the major league lead with Baltimore’s Jim Johnson.

Chris Davis drove in two runs with a double, making him the first player in Orioles history to have 40 doubles and 40 homers in a season. Danny Valencia tied a career high with four hits, and Roberts had three singles.

Baltimore outhit New York 13-6.

Before the game, the Yankees announced that shortstop Derek Jeter would miss the rest of the season with an injured left ankle. The Yankees captain played in only 17 games this season and made four trips to the disabled list.

TIGERS 1, WHITE SOX 0

CHICAGO (AP) — Anibal Sanchez struck out 10 for Detroit.

Sanchez (14-7) allowed five hits and walked four in 7 1-3 innings while lowering his AL-best ERA to 2.50. Joaquin Benoit got three outs for his 18th save in as many opportunities, completing a five-hitter for Detroit’s 11th shutout of the season.

Omar Infante drove in the game’s only run with a two-out single against Matt Lindstrom (2-4) in the eighth inning.

White Sox left-hander Jose Quintana pitched seven innings of five-hit ball. He remained winless over his last five starts despite a 3.03 ERA.

Every Oakland starter had at least one hit, one run and one RBI as the A’s recorded a season-high 22 hits and extended their lead over Texas in the AL West to three games.

Lowrie, Coco Crisp and Stephen Vogt also homered. Yoenis Cespedes had three RBIs to help the A’s score their most runs in a game since beating Boston 20-2 on Aug. 31, 2012.

With runners on second and third and three runs already in, Lowrie lined a ball down the line in the fourth that first-base umpire Bill Miller ruled foul as he danced out of the way.

Lowrie pointed at the ground inside the white line where he thought the ball hit. Oakland manager Bob Melvin came out to argue, and Lowrie was eventually awarded a two-run double after the entire umpire crew huddled and changed the call.

Twins manager Ron Gardenhire was ejected by Miller after a long argument.

Sonny Gray (3-3), who had received fewer than four runs of support over his last six starts, struck out seven in five innings for the win.

In the fifth, Josh Reddick of the A’s drove a ball off the top of the wall in the right-field corner that Miller ruled a home run.

The call was overturned after a replay review — the first at Target Field this season — and Reddick had to trot back out of the dugout to second base.

Mike Pelfrey (5-12) was removed with no outs in the fourth. He allowed seven runs and eight hits and has won just once since July 11.

ROYALS 6, INDIANS 2

CLEVELAND (AP) — Alex Gordon homered on the game’s first pitch and Kansas City’s James Shields dominated after a shaky first inning.

Kansas City took two of three in the series between clubs that are in contention for the second wild card spot in the AL. The Royals, who entered Wednesday trailing Tampa Bay by three games, moved a game closer to the Indians. Cleveland was 1 1/2 games behind the Rays.

The Royals had a home run, a triple and a single on the game’s first seven pitches to take a 2-0 lead.

Shields (11-9) gave up two runs, two hits, and hit a batter in the bottom half of the first before taking control.

Michael Brantley had a two-run single in the first, but Shields didn’t allow another hit until Jason Kipnis’ leadoff single in the ninth.

Shields allowed four hits, struck out seven and walked one. Greg Holland retired the last three hitters for his 42nd save.

Mark Trumbo hit a two-run home run, his career-high 33rd, and Josh Hamilton had three hits as the Angels won for the ninth time in 12 meetings with the Blue Jays.

Mike Trout drew a one-out walk off Steve Delabar (5-3) in the eighth and went to third on Hamilton’s double. Trumbo was intentionally walked to load the bases for Calhoun, who hit a sacrifice fly to left.

Calhoun went 1 for 2 with two sacrifice flies, helping the Angels win for the fifth time in seven games.

Wilson (16-6) allowed four runs, three earned, in seven innings to match his career-high in victories, first set with Texas in 2011. The left-hander, who has not lost since July 5 against Boston, walked four and struck out six. He’s 12-1 with a 3.02 ERA in 17 starts since June 14.

Ernesto Frieri worked the ninth for his 32nd save.

Moises Sierra went 3 for 4 with two doubles and a triple for the Blue Jays.

ASTROS 6, MARINERS 1

SEATTLE (AP) — Brad Peacock gave up one run in six innings and Chris Carter singled in two runs to lead Houston to the three-game sweep.

Kendrys Morales hit the 100th home run of his career for Seattle, which has lost four straight at home.

Peacock (5-5) allowed four hits, struck out four, walked one and retired the final nine batters he faced. Josh Zeid got out of an eighth-inning jam and finished the ninth for his first career save.

Brandon Maurer (4-8) allowed five runs — all scoring with two outs — and seven hits in three innings. It was the first major league start for Maurer since May 28. He was pressed into duty to replace ace Felix Hernandez, who was originally scheduled for the start but was scratched Monday with a minor oblique strain.

Justin Morneau, acquired from Minnesota less than two weeks ago, snapped an 0-for-14 slump with four hits while scoring twice for the Pirates.

Texas has lost nine of its last 12, a stretch in which the Rangers have lost four consecutive series. They have gone from a three-game lead in the AL West to entering Wednesday 2 1/2 games behind Oakland.

A.J. Burnett (8-10) struck out seven in 6 1-3 innings, though he faded late after retiring the first 13 batters he faced.