NEW YORK -- The Baltimore Orioles were experiencing a flat offense and were three innings away from a potentially damaging sweep at Yankee Stadium.
Once they were able to get Andy Pettitte out of the game, things changed in a flash.
J.J. Hardy and Adam Jones each hit a three-run home run in the top of the seventh inning and the Orioles rallied for a 7-3 victory over the New York Yankees Sunday afternoon.
The Orioles had been blanked for 18 innings, going 9-for-62 since Nick Markakis had a two-out RBI single in the sixth inning Friday. They had three hits against Ivan Nova Saturday and did not fare much better early on Sunday, getting five hits in the first six innings against Pettitte.
Then Michael Morse and Danny Valencia were able to square up fastballs for singles that ended Pettitte's day at 93 pitches. That seemed to breathe new life into the Orioles as they followed up four more hits against three relievers.
"He threw the ball well," Jones said. "I know he's going to get a quality start but we're just glad he didn't get the win. He is who he is. He's a first-ballot Hall of Famer to me, 41, 42 years old and still going out there and carving hitters up, making me foul it off my shin, breaking bats.
"He's still very impressive, you tip your hat to him but when we seen him leave the game, trust me, I don't think anybody was sad about that. I think we were a little bit happy; let's change it up, and a change of scenery worked for us."
Shawn Kelley was the first Yankees reliever, and Baltimore ended its shutout streak with an RBI single by Matt Wieters. On the next pitch, Hardy gave the Orioles the lead for good with his 24th home run as his fly ball just scraped over the right field wall.
After Boone Logan put two on, Manny Machado fouled out to Chris Stewart on a bunt attempt against Joba Chamberlain. Three pitches later, Jones crushed Chamberlain's 1-1 slider over the center-field fence for his 28th home run.
"We needed it badly," Jones said. "We've been grinding. Things haven't fallen into our place and gone our way and the first six innings. We couldn't muster back-to-back hits but the seventh inning was huge."
Hardy said: "We were a little flat. We could all feel it. That was big for us. Hopefully that jump-starts our September."
The Orioles won for the seventh time in their last 18 games and moved ahead of the Yankees by a half-game in the AL wild card race. They are three and a half games behind the Tampa Bay Rays for the second wild card spot.
Kevin Gausman (2-3) struck out three in two scoreless innings for the win after starter Wei-Yin Chen labored through four innings. Chen allowed three runs and four hits along with a career-high five walks while throwing 82 pitches.
Francisco Rodriguez pitched a hitless seventh, Tommy Hunter stranded two in the eighth and Darren O'Day pitched a hitless ninth.
The Yankees lost for the seventh time in their last 21 games and also had a season-high seven-game home winning streak snapped. They scored their runs without home runs as Alfonso Soriano had an RBI single in the third, Brett Gardner drew a bases-loaded walk and Derek Jeter lifted a sacrifice fly in the fourth.
"When you win the first two and have 3-0 (lead), you get greedy," New York manager Joe Girardi said. "That's the hardest part."
Their bullpen squandered a lead for just the 11th time this season and first time since Aug. 11 against the Detroit Tigers in a game the Yankees wound up winning 4-3. New York relievers entered the deciding inning with a 1.05 ERA over its last 42 1/3 innings since Aug. 15.
"They've been so good for us all year long," Girardi said. "They're not going to be perfect but it is surprising."
Alex Rodriguez returned from missing Saturday's game with flulike symptoms and went 0-for-3.
Pettitte was in line for his ninth straight victory over the Orioles as he allowed one run and seven singles in six-plus innings. He exited to a standing ovation before the Orioles erupted.
"Anytime you turn it over to our bullpen, you feel good about it so I kind of .. I know if I'm in any trouble late in the game, he's been going to the bullpen," Pettitte said. "And they've been so great that you can't fault him for that. It just didn't work out today."
NOTES: Both teams announced their first round of September callups. For the Yankees, IF David Adams and RHPs Brett Marshall and Dellin Betances were recalled from Class AAA Scranton/Wilkes-Barre. The Yankees also purchased the contract of C J.R. Murphy and LHP Cesar Cabral from Scranton/Wilkes-Barre. IF Jayson Nix (fractured left hand) was moved to the 60-day disabled list while OF Melky Mesa was unconditionally released. ... Baltimore made a trio of moves involving catchers by adding Steve Clevenger and Chris Snyder from Class AAA Norfolk. Since Snyder was not on Baltimore's 40-man roster, Taylor Teagarden was designated for assignment. ... Former Tennessee women's basketball coach Pat Summit took part in a pregame ceremony as a part of "Worldwide Alzheimer's Awareness Month."