Rosales led off the eighth with his second home run of the year, a shot that landed halfway up the staircase beyond the left-field fence.
"I haven't gotten too many starts against right-handers," Rosales said. "I appreciate the opportunity. The crowd really pumped me up and I just ran."
A's starter Jarrod Parker threw his best game of the year, allowing a run on four hits over a season-high seven innings. He walked two and struck out five.
"It's a step in the right direction," Parker said. "The last couple of starts I tried to piece things together. This time I tired to power through the ball and was getting ground balls."
Parker, who retired 10 of the final 11 batters he faced, threw 98 pitches, 60 for strikes, through seven innings.
"Getting him on track would be huge," A's manager Bob Melvin said. "He seemed like he had a calm to him. Right away he was throwing strikes. Hopefully this is a springboard for him. He was really good."
Parker retired seven of the first eight hitters he faced, and then had a strong finish.
"I just want to attack," Parker said. "I want to be in the zone when I want."
Rosales said Parker's effort was the reason the A's were able to come back and win the game against a tough pitcher like James Shields, who threw his 21st career complete game.
"All of his pitches were working," Rosales said. "You look at the way Parker kept us in it, and that let J.D. and myself get those hits and have this game turn out good for us."
Parker had allowed six homers and 16 runs over his previous four starts, two for wins. He's seen his ERA dip a full two runs since then.
"That was such a huge pickup for us," Parker said of Rosales' home run. "It was a big hit for us. Even J.D.'s hit was huge."
Sean Doolittle (3-0) pitched a scoreless eighth for the win. He has not allowed a run over his past nine appearances, a total of 8 1/3 innings.
"We feel that's one of our strengths," Melvin said. "Doolittle has been lights out recently. We feel good when we're in close games at home."
Grant Balfour pitched the ninth for his seventh save in as many chances.
"We didn't have any chances," Royals manager Ned Yost said. "David Lough picked up the one RBI and we just couldn't get anything going all night long."
Shields had retired 11 straight before Donaldson led off the seventh with his sixth home run of the year, a line drive that one-hopped the advertising sign above the out-of-town scoreboard in left field.
"It was just a case of me not doing my job. Bottom line. I don't really care what the score of the game is, I just didn't get the job done at the end," Shields said. "It's a tough loss right there, a real tough loss."