The Yankees overcame Chris Davis' major league-leading 33rd home run and yet another double from Manny Machado, who was celebrating his 21st birthday. The Orioles have lost four of five.
The 41-year-old Pettitte (6-6) earned his 251st win, tying Hall of Famer Bob Gibson for 44th place on the all-time list.
Pettitte stretched his unbeaten streak against Baltimore to 11 starts dating to 2007, winning eight times. Overall, he is 28-6 against the Orioles — only Yankees great Whitey Ford (30) has beaten the Birds more often since the franchise moved from St. Louis to Baltimore for the 1954 season.
Mariano Rivera worked the ninth for his 29th save.
Nunez came off the 60-day disabled list before the game and played for the first time since a strain on his left side slowed him in early May. His key hit helped end a seven-game winning streak by Chris Tillman (10-3). Nunez had a sac fly in the second, singled and scored in the fifth and knocked in the go-ahead run with a single in the sixth.
ANGELS 9, RED SOX 7, 11 innings
ANAHEIM, Calif. (AP) — Josh Hamilton hit a two-run homer in the 11th inning, after the Angels rallied to tie it with four runs in the ninth, and Los Angeles beat Boston to snap the AL East-leaders' five-game winning streak.
Brad Hawpe singled with one out in the 11th against Craig Breslow (2-2). Hamilton drove the next pitch out to right-centre for his 12th homer and second dramatic blast in three nights.
Dane De La Rosa (4-1) earned this victory with a scoreless inning.
Boston was leading 7-3 in the seventh when Andrew Bailey relieved injured pitcher Andrew Miller with one out and runners at the corners. He retired Mike Trout on an inning-ending double play. Bailey then pitched a scoreless eighth before the Angels loaded the bases with two out in the ninth against Alex Wilson.
Red Sox closer Koji Uehara gave up a two-run single to Albert Pujols and an RBI single to Hamilton before Howie Kendrick hit a grounder to third baseman Brandon Snyder. But Snyder's throw to second base sailed into right field, allowing Collin Cowgill to score the tying run.
It was Uehara's third blown save in eight chances.
TIGERS 9, INDIANS 4
CLEVELAND (AP) — Torii Hunter drove in three runs, Miguel Cabrera cracked a two-run homer and Detroit dominated Cleveland for its fifth straight win.
Hunter hit a two-run homer, tripled and doubled as the Tigers won their seventh straight over the Indians and increased their lead in the AL Central to 3 1/2 games. Detroit is 8-2 against Cleveland, and the Tigers have outscored the Indians 16-4 in winning the first two of the four-game set.
Anibal Sanchez (7-5) returned from the disabled list and pitched five innings for his first win since June 4. Cabrera and Prince Fielder homered in the third off Carlos Carrasco (0-4), who was recalled from the minors to face the AL's best hitting team.
TWINS 6, BLUE JAYS 0
TORONTO (AP) — Brian Dozier hit a three-run home run, Mike Pelfrey and three relievers combined for a four-hitter and Minnesota beat Toronto.
Dozier had two hits and four RBIs, connecting off knuckleballer R.A. Dickey for his eighth homer as the Twins snapped a six-game skid and won for just the fourth time in 14 games.
Minnesota came in having lost 17 of 23 to Toronto, including eight of nine at Rogers Centre.
Pelfrey (4-6) snapped an eight-start winless streak to earn his first victory since May 5 at Cleveland. He allowed three hits in six innings, walked three and struck out two.
Dickey (8-9) gave up six runs and seven hits in seven innings. He struck out three.
ROYALS 4, ATHLETICS 3
KANSAS CITY, Mo. (AP) — Jarrod Dyson delivered an infield single with the bases loaded and two outs in the eighth inning, giving Kansas City a scrappy victory over Oakland.
The Royals had rallied to tie the game on a sacrifice fly by Eric Hosmer in the seventh, and then loaded the bases on an error and a pair of walks by reliever Ryan Cook.
Dyson, hardly known for his power, showed bunt on his first pitch from Cook (1-2) before hitting a grounder deep behind second base. Shortstop Adam Rosales fielded it cleanly but didn't even bother with a throw as pinch runner Alcides Escobar scored the go-ahead run.
Aaron Crow (6-3) worked the eighth and Greg Holland handled the ninth for his 20th save.
RAYS 3, WHITE SOX 0
ST. PETERSBURG, Fla. (AP) — Matt Moore won his fourth consecutive start to help Tampa Bay beat All-Star selection Chris Sale and the Chicago White Sox.
Moore (12-3), who could still become an All-Star as an injury replacement, gave up five hits, two walks and struck out six in 6 1-3 innings.
The Rays have won seven of eight, improving to a season-best eight games (48-40) over .500. Fernando Rodney, the third Tampa Bay reliever, pitched the ninth for his 19th save — completing the six-hitter.
Sale (5-8) allowed three runs, six hits, one walk and had nine strikeouts in seven innings for the White Sox, who have lost eight of 10. The left-hander, despite giving up just 20 runs — 17 earned — over 49 1-3 innings, is 0-6 in his last seven starts.
ASTROS 9, RANGERS 5
ARLINGTON, Texas (AP) — Jason Castro hit a tiebreaking three-run homer hours after being chosen for his first All-Star team, and Houston beat Yu Darvish and Texas.
The catcher's drive came off Robbie Ross in the seventh inning but made a loser of Darvish (8-4), who had a rough night after earning his second All-Star nod in two years in the majors.
The Astros built a 4-0 lead on a two-run homer by Brandon Barnes in the fourth and a two-run single from fellow rookie Marc Krauss an inning later.
Geovany Soto pulled the Rangers even in the sixth, following Mitch Moreland's sacrifice fly, with a three-run homer off Wesley Wright.
Travis Blackley (1-0) got the win with 1 1-3 innings of scoreless relief.
Darvish came out after walking Jose Altuve to start the seventh, and Brett Wallace was hit by a pitch from Ross. Castro, who had two hits and scored twice, followed with his 12th homer. Wallace reached base five times, adding two doubles and two walks.
Darvish, the major league strikeout leader, had six in six innings, but gave up six hits and a season-high five earned runs.