KANSAS CITY, Mo. - As the Yankees' losing streak hit four, Joe Girardi kept it strictly positive regarding his club's virtually nonexistent hitting.

"It's just what happens with offenses," Girardi said after a 12-1 loss to the Royals Friday night. "Teams go through little times where they don't hit as well as others. It's no fun when you're going through it, but our guys will come out of it."

Through four innings Saturday night, the Yankees sure hadn't, but Chase Headley changed that with one swing.

The third baseman, struggling at the plate along with most of his teammates, ripped a tiebreaking three-run homer with two outs in the fifth inning of a 5-1 victory over the Royals in front of 31,871 at Kauffman Stadium.

Girardi said of Headley's homer: "It changed the complexion of the game . . . Obviously, it really picked up the dugout a little bit. It changes the feeling because we've been struggling to score runs since that first day in Tampa and all of a sudden we get three quick ones.''

Alex Rodriguez added his 10th homer of the season, a blast to rightfield off Joe Blanton in the ninth inning, to make it 5-1.

It was hardly a breakout performance for an offense that came in having scored six runs during the four-game skid, but it was more than enough for CC Sabathia, who turned in his best outing of the season in winning for the second straight start.

Against a team that lit up the Yankees the night before, Sabathia (2-5, 4.67) was his vintage self. He allowed one run, six hits and no walks in seven innings, striking out five and throwing 87 pitches, 64 of them strikes.

Dellin Betances pitched a perfect eighth and Andrew Miller, with his save chance taken away by A-Rod's 664th career homer, pitched a perfect ninth. Sabathia and the two relievers retired the last 14 Royals batters. "It's a good team,'' Sabathia said, "so to be able to come in here and get a win, especially after what they did last night, feels good.''

The Yankees (22-16) entered the fifth with only one hit against Danny Duffy (2-3, 5.87). With two outs, Mark Teixeira, who walked in the first and third innings, singled to left. Carlos Beltran, showing signs of life at the plate, also singled to left.

Up stepped Headley, who had a .192/.241/.308 slash line in his previous eight games. After falling behind 0-and-2, he worked the count full before turning on an 84-mph changeup and sending it into the Royals' bullpen for his fifth homer and a 4-1 lead.

"Big hit,'' Headley said. "Obviously, we've been grinding a little bit to score runs, and myself personally doing the same, so I got down in the count, was able to fight my way back into it and finally got a pitch I could handle and I put a good swing on it.''

Duffy walked Jacoby Ellsbury to start the third and issued one-out walks to Rodriguez and Teixeira (who battled back from an 0-and-2 count) to load the bases. Beltran's first-pitch sacrifice fly made it 1-0.

Omar Infante, who had three hits Friday night, led off the bottom of the third with a single and No. 9 hitter Paulo Orlando followed with a bunt single, reaching as Sabathia made a poor throw to a late-covering Jose Pirela.

Alcides Escobar's single loaded the bases for Mike Moustakas, coming off a 4-for-5 performance the night before. His sacrifice fly made it 1-1 and also allowed Orlando to reach third.

But Sabathia shut it down there, striking out Lorenzo Cain, who drove in five runs Friday night, and Eric Hosmer to end the inning.