The victory was the fifth straight for the Royals and gave them wins in 13 of their last 16 games. They stayed 2 1/2 games behind victorious Detroit, the American League Central leader, and maintained their hold on the second Wild Card berth.
Butler, who had a fretfully slow season until recently, has hit .400 (18-for-45) in his last 13 games with four doubles, four homers and 11 RBIs.
"I'm just trying to stay where I'm at; I'm feeling real good up there," he said.
He began in the first inning with a booming two-run homer that carried 422 feet toward the Royals Hall of Fame in left field. It came off left-hander Madison Bumgarner, earlier the victim of Omar Infante's double to left.
"If you're going to get a guy like Bumgarner, you better do it early and we did, thanks to Billy's two-run homer in the first inning," said Royals manager Ned Yost.
The Giants came back for a 2-2 tie in the third, an inning that could have been more productive if the Royals had not had a successful challenge under the replay review system.
Hunter Pence was ruled out after being called safe on a play at third base. That made two outs, but the Giants added three more hits against Royals left-hander Jason Vargas, runs scoring on Joaquin Arias' double and Matt Duffy's single.
The inning ended as right fielder Nori Aoki threw out Arias at the plate, his second assist of the inning to tie a Royals record.
Vargas, in his second start since an appendectomy, ran up a pitch total of 109 in five innings and was pulled out of the game.
"He's just still not quite sharp after his surgery," Yost said. "My whole focus was to get him through the fifth inning ahead or at least tied because I knew we had the matchups to protect that lead the rest of the way."
Jason Frasor took over and worked a perfect sixth inning.
"People don't think baseball is a game of momentum, but you get a 1-2-3 inning and sometimes it'll carry over to the offense," Frasor said. "Get through the sixth and it lines up well."
Sure enough, in the sixth, Butler put the Royals ahead with a single after some Giants fielding miscues.
"Bum threw a great game. We got sloppy there in the one inning; it cost us a couple of runs," Giants manager Bruce Bochy said.
Infante drilled a one-out single, and first baseman Michael Morse dove to snag Salvador Perez's grounder but his throw to second base pulled Duffy off the bag. Then Duffy flung the ball past first base. Errors were assessed to both Morse and Duffy, putting runners at the corners.
Butler bounced a single into right field to score Infante, and Gordon dropped an RBI double into left field, getting Perez home. However, Butler was tagged out at third base and Lorenzo Cain flied out to end the inning. But the Royals had a two-run lead.
Butler's single turned out to be as important as his homer.
"Even though it wasn't hit hard, it wasn't pretty, it was huge because that got us to our power arms with a lead," Yost said.
The Royals' usual bullpen plan then unfolded.
"You can't set it up any better," Yost said.
Kelvin Herrera worked a scoreless seventh, working past a one-out single. Wade Davis had a bigger challenge after singles by Pablo Sandoval and Morse. But he struck out pinch-hitter Joe Panik and got Duffy to rap into a double play.
Closer Greg Holland breezed through a perfect ninth for his 33rd save and the 100th of his career.
So the Royals' five pitchers combined to prevail over Bumgarner, who went the distance.
After arriving in Kansas City from a series in Arizona at 3:15 a.m. CT on Friday, the Royals might have expected to be sluggish in the evening but they shook it off.
"To get a win against a guy like Bumgarner, especially with the travel day we had, was huge," Gordon said.
The Royals now have a 50-8 record in games where they score at least four runs, compared to 11-45 when they don't.
"Our magic number is four and to get four off a guy like that, we feel pretty good about that," Butler said.