KANSAS CITY, Mo. (AP) -- Down seven runs with San Francisco ace Tim Lincecum on the mound, things sure looked bleak for the Royals.
Once they got him out of the game, though, all bets were off.
Seven different Royals drove in runs, including a pair of RBIs from David DeJesus, and Kansas City belted out 14 hits. The comeback matched the second-best in Royals history, after a nine-run rally on June 15, 1979, at Milwaukee.
"When we got it to 10-5, the talk in the dugout -- and they were accurate -- was that we had the momentum even though we were down five runs," Royals manager Trey Hillman said. "Today was a grinding out kind of day to comeback from a big deficit against a real good starting pitcher. It's one of those situations of never quitting as far as a mental mindset, feeling we had a chance against Lincecum and their bullpen."
Lincecum took a 10-3 lead into the bottom of the fifth. The Royals scored two in the inning on Jose Guillen's single and Alex Gordon's sacrifice fly, then sent 11 batters to the plate in a five-run sixth that tied it up.
Left-hander Ron Mahay (3-0) worked two hitless innings to pick up the victory, and Joakim Soria worked the ninth for his 20th save in 21 opportunities. He had retired 18 in a row before Randy Winn's two-out single in the ninth.
"There were so many things when you lose a game like that," Giants manager Bruce Bochy said. "It goes to show that you have to play hard for nine innings, and they did. They shut us down the last four innings and we had trouble shutting them down. This was an ugly game for both sides, really."
Winn went 4-for-5 and had three RBIs for the Giants, and John Bowker drove in three runs with a bases-clearing double in the fifth that helped push their advantage to seven runs.
That's when Kansas City, sporting throwback Monarchs uniforms, started to rally.
The Royals closed within 10-5 against Lincecum, chasing him after five innings, and got four consecutive hits against reliever Keiichi Yabu in the sixth. Jack Taschner and Vinnie Chulk didn't fare much better, with the Royals getting run-producing singles from Ross Gload, Alberto Callaspo and DeJesus.
Aviles' two-out, two-run double tied the game at 10-10.
"We didn't fold over," Aviles said. "We just kept battling back, getting a run here, a run there, and the next thing you know we're up 11-10 and everything is in our favor. If you're in this game and you don't feel like you can win, you're probably not in the right business."
Gathright's seventh-inning single drove in Callaspo, who reached on a fielding error by Emmanuel Burriss, with the go-ahead run.
Alex Hinshaw (1-1), the fifth of six Giants pitchers, took the loss after giving up the unearned run.
Fred Lewis had three of the Giants' 16 hits, extending his personal hitting streak to a career-high 12 games. He drove in a run, walked twice and scored two runs.
Lincecum gave up five runs on six hits, two walks and two wild pitches, while striking out eight and throwing 109 pitches in his shortest start of the season.
DeJesus energized the Royals by scoring from second on a wild pitch in the third inning and bowling over Lincecum covering home.
"That wakes you up a little bit, no doubt," Hillman said.
Said DeJesus: "When I made it to third, I saw the catcher was trying to find the ball, so I took a chance. It worked out. He was in the way. I was just trying to get a run and get us going. That gave us that little spark."
Lincecum said that play did not effect his pitching.
"I fell on my back," he said. "It had nothing to do with the outcome. I had trouble finding my rhythm. It was a lack of focus on my part. I've just got to find a way to get the job done and minimize the damage. We had a chance to step on their throat when they were down and we didn't do it. I didn't help with that and I'm pretty disappointed in myself."
Royals starter Kyle Davies, who was 3-0 with a 1.46 ERA in his first four starts since a May 31 promotion from Triple-A Omaha, lasted just 1 1/3 innings, permitting five runs. He faced 12 batters and eight reached base -- six hits and two walks.
Reliever Jeff Fulchino didn't do much to slow down San Francisco, either, giving up four runs on seven hits and three walks in three innings.
Aviles' three-RBI game was a career high. ... Lewis is hitting .391 in his hitting streak.