KANSAS CITY, Mo. -- Just when it appeared the Houston Astros were going to extend their winning streak to 12 games, their bullpen imploded.
Mike Moustakas went 4-for-5 with a two-run ninth-inning walk-off homer as the Kansas City Royals rallied to beat the Astros 9-7 on Tuesday night.
"We never feel like we're out of a game, dating back to three or four years ago," Moustakas said. "Just doing what we can, keeping the line moving and we were able to do that tonight."
Moustakas hit his team-leading 15th home run with two out off Ken Giles (0-1) after Salvador Perez singled.
"We didn't stop and feel like we were out of the game," Royals manager Ned Yost said. " Guys were continuing to battle. Guys were continuing to compete offensively. You just had a good feeling about it."
Whit Merrifield, who had his 19-game hitting streak snapped Monday, hit a bases-clearing double with two out in the eighth to tie the score at 7 off Giles. Moustakas' single scored Perez for the first Kansas City run of the inning.
The Royals trailed 7-1 entering the bottom of the fourth.
"It's really frustrating," Giles said. "I didn't make my pitches when I needed to. I let my team down. It's all on me. With my failures it's my fault. I need to do better. I need to make pitches when I need to. They did great. They had a great game. It was just one flaw from me.
"The slider wasn't working today. I had great fastball command. I threw the fastball where I needed to. I couldn't put them away with my slider. No excuses."
The Astros had not blown more than a two-run lead in a loss this season prior to the Royals' comeback.
Mike Minor (2-1), the fourth Kansas City pitcher, worked a perfect ninth to pick up the victory. Royals relievers Kevin McCarthy, Travis Wood and Minor worked 5 1/3 scoreless innings after rookie Jakob Junis was pulled.
On the other end of the spectrum, Astros relievers Reymin Guduan, James Hoyt and Giles allowed seven runs while retiring only five of the 12 hitters they faced in the eighth and ninth innings.
"He's thrown a lot of (sliders)," Astros manager A.J. Hinch said of Giles. "I think any time you show a hitter four or five of them, in an at-bat it's going to educate him a little. It looked like the one that Merrifield hit kind of sat up, backed up a little bit on him. He put a good swing on it. We've seen him put away guys with a lot of sliders in a row. Tonight wasn't his night."
Astros starter David Paulino allowed three runs on eight hits over 5 2/3 innings.
Eric Hosmer doubled to open the sixth and scored on a Moustakas single.
Yuli Gurriel, who hit a three-run ninth-inning homer Monday, stroked a two-run single in a three-run third. Gurriel laced a single to left, scoring Carlos Beltran and Evan Gattis.
The Astros tacked on four more runs in the fourth. Reddick's double scored Springer with the first run of the inning. Reddick scored from second on Carlos Correa's infield single.
Beltran's eighth home run with Correa aboard capped off the inning and finished the night for Junis.
"There was no doubt," Beltran said that the Astros would win. "It seems like every time we get ahead in the game we win those ballgames."
Junis permitted seven runs on nine hits and three walks in 3 2/3 innings before being replaced by Kevin McCarthy.
Alex Gordon homered for the Royals in the third off Paulino, who was making his third big league start. It was Gordon's first home run of the season.
The Royals got another run in the fourth on back-to-back doubles by Hosmer and Perez.
NOTES: The Royals optioned RHP Seth Maness to Triple-A Omaha to make roster space for RHP Jakob Junis. Maness was 1-0 with a 3.72 ERA in eight relief appearances. ... Astros 3B Marvin Gonzalez will likely miss a couple of games with a bruised left hand. The Astros have ordered a protective pad for his left hand. ... The Astros have scored at least six runs in nine consecutive games. The last team with a longer streak was the 2004 Astros (11). ... LHPs Dallas Keuchel of the Astros and Jason Vargas of the Royals are the Wednesday probables.