Fortunately for Pettitte, most of his later offerings landed in the right spot.
Pettitte (6-6) persevered on a hot, sticky day, hanging in after the Orioles took an early 3-0 lead and ending his four-start winless string.
"I've been frustrated," he said. "Every decision you're making, you feel like it's not the right one."
The 41-year-old Pettitte 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.
Pettitte got a big cheer when he trotted off with two outs in the seventh inning after 100 pitches.
"It was smokin' hot," he said. "Didn't want my guys standing out there in the heat."
Mariano Rivera worked the ninth for his 29th save.
The Yankees overcame Davis' major league-leading 33rd home run and yet another double from Manny Machado, celebrating his 21st birthday. The Orioles have lost four of five.
"Anytime you're leading early in the game, you expect to continue to lead, or at least put up some more runs," Davis said.
"One- and two-run leads in this game don't last very long, especially in this ballpark and with their offense," he said.
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 sacrifice fly in the second, then singled and scored in the fifth. It was 4-all when Lyle Overbay opened the sixth with a single against Tillman and advanced on a two-strike sacrifice bunt by Luis Cruz.
Next up was Nunez, and he singled up the middle. Overbay brushed past catcher Taylor Teagarden with a headfirst dive.
Nunez didn't bat much during his rehabilitation assignment. He got three hits Friday night for Double-A Trenton.
"Nuney is kind of a free spirit. I don't think he thought a lot about not having a lot of at-bats," manager Joe Girardi said.
Davis put the Orioles ahead by lofting a high fly ball that kept drifting, carrying over Brett Gardner's leap. He matched his career high in home runs and RBIs (85), both achieved during the entire 2012 season.
Davis is tied for seventh-most homers by the All-Star Game and still has more than a week to play before the break. Barry Bonds holds the mark with 39, followed by Reggie Jackson and Mark McGwire with 37 each, STATS said.
Machado hustled for his 39th double. That's the second most before the All-Star break, trailing only the 42 by Edgar Martinez in 1996, STATS said.
The gametime temperature was 91 degrees, and the steamy conditions took their toll.
Baltimore outfielders Nick Markakis and Nolan Reimold waited out a pitching change on one knee in the grass. Cano stepped out of the batter's box and glanced at the sky after the cloud cover seemed to distract him.
The Orioles acquired INF-OF Alex Liddi from Seattle. Baltimore also got international signing slot No. 3 and sent the No. 2 spot to the Mariners. The 24-year-old Liddi was designated for assignment on June 28 after going 1 for 17 with Seattle. He'll join Triple-A Norfolk. ... Yankees RHP Hiroki Kuroda (7-6, 2.95) will start Sunday, bumping Phil Hughes back a day. Kuroda skipped a start because a tweaked hip flexor. RHP Jason Hammel (7-5, 5.19) pitches for the Orioles in the series finale. ... Yankees SS Derek Jeter was set to begin a rehabilitation assignment Saturday night for Triple-A Scranton/Wilkes-Barre. ... Orioles DH Brian Roberts batted fifth as a starter for the first time in his career. ... Also on the list of most homers by the All-Star break: Luis Gonzalez and Ken Griffey Jr. (35), Frank Howard (34) and Roger Maris, Sammy Sosa, Matt Williams, McGwire and Griffey, STATS said.