NEW YORK (AP) -- A day after being shut out on three singles, J.J. Hardy and the Baltimore Orioles got blanked for six innings Sunday on what was shaping up as a lost weekend.
''We were a little flat. We could all see it, we could all feel it,'' Hardy said.
That all changed in a hurry.
Hardy and Adam Jones hit three-run homers during a seven-run burst in the seventh as Baltimore suddenly broke loose, jolting the New York Yankees 7-3 to avert a sweep in a matchup of wild-card contenders.
''Hopefully, it jump-starts us in September,'' Hardy said.
The Orioles rallied against Andy Pettitte and a faltering bullpen. Michael Morse lined a leadoff single to begin the comeback from a 3-0 deficit. Acquired from Seattle on Friday, he got two hits in his Baltimore debut.
''We just needed a little spark there,'' Morse said.
Hardy's shot against Shawn Kelley (4-2) glanced off the glove of right fielder Curtis Granderson and put the Orioles ahead 4-3. After reliever Boone Logan gave up a bunt single and walk, Jones homered to dead center field came against Joba Chamberlain.
''It was tough today. A chance for us to sweep and it is completely on me,'' Kelley said.
The seven runs matched the Orioles' biggest inning of the season. It also tied the most allowed by the Yankees in an inning this year.
''We needed it big,'' Jones said. ''Things hadn't fallen into place.''
The Orioles won for the second time in six games on a road trip that includes three more games at Cleveland.
The Yankees had beaten Baltimore two in row while extending their home winning streak to six. New York had been 32-0 at home this year when leading by at least two runs, the Elias Sports Bureau said in research provided by the Yankees.
Rookie Kevin Gausman (2-3) pitched two scoreless innings after starter Wei-Yin Chen walked a career-high five on a sticky afternoon. Gausman's other win came against the Yankees on June 28 with 4 1-3 scoreless innings.
Four Baltimore relievers combined for five shutout innings.
Brett Gardner doubled twice and drew a bases-loaded walk for the Yankees. But Robinson Cano and Derek Jeter each struck out three times and Alfonso Soriano was thrown out at first on a sensational play by charging third baseman Manny Machado.
Pettitte has beaten Baltimore 29 times in the regular season and playoffs, and seemed to be cruising through six innings. He had walked none, worked around five singles and wasn't in trouble.
But Morse and Danny Valencia opened the seventh with sharp singles, and Yankees manager Joe Girardi made the first of his several trips to the mound.
''Any time you turn to our bullpen, you feel good about it. It just didn't work out today,'' Pettitte said.
''They send you out there to get guys out and I gave up two hits that started a rally,'' he said. ''You can't second-guess with our bullpen. We have the best bullpen in the league, in my opinion.''
Not on this day, though.
Matt Wieters greeted Kelley with an RBI single. Hardy, who broke an 0-for-13 rut with an earlier single, hit the first pitch for his 24th home run. Granderson got his glove on the opposite-field drive as he ran back and reached above the wall.
''I couldn't tell the exact angle of where it landed, but I made a little bit of contact with the ball and a lot of contact with the wall,'' Granderson said. ''It's not a routine play but a chance to make an exciting one.''
Jones connected for his 28th homer.
Soriano hit an RBI single in the third. The Yankees scored two more in the fourth on Gardner's walk and a sacrifice fly by Jeter.
NOTES: Jeter moved past Bernie Williams for sixth on the Yankees' career RBIs list with 1,258. ... Baltimore is 8-7 against the Yankees this year. ... Yankees 3B Alex Rodriguez returned after missing a day with flu-like symptoms. His sun shades fell off while he chased Valencia's early infield single ... Yankees RHP Phil Hughes (4-13, 4.91) pitches Monday at home against White Sox LHP Jose Quintana (7-4, 3.66). ... RHP Bud Norris (9-10, 4.13) starts for the Orioles on Monday at Cleveland against RHP Justin Masterson (14-9, 3.49). ... Former Tennessee women's basketball coach Pat Summitt was joined by Girardi behind home plate for a pregame ceremony to raise awareness during World Alzheimer's Month. The record-breaking coach stepped down in April 2012 because of early-onset dementia, Alzheimer's type.