KANSAS CITY, Mo. — Mike Moustakas' no-doubt homer ended the Kansas City Royals' unlikely comeback against baseball's best team.

Moustakas hit a two-run shot with two outs in the ninth inning after Kansas City rallied from a six-run deficit, and the Royals snapped the Houston Astros' 11-game winning streak with a 9-7 victory Tuesday night.

Moustakas drove an 0-1 slider from Ken Giles (1-2) out to right with Salvador Perez aboard. Moustakas had four hits and three RBIs.

"He threw a fastball, first pitch, middle in and the guy throws hard," Moustakas said. "I fouled it off and was kind of looking for something out over the plate. Got a slider out there and put a good swing on it."

Kansas City trailed 7-1 in the fourth inning but completed its comeback with a four-run eighth. Whit Merrifield hit a three-run double with two outs in the inning to tie it at 7.

Merrifield drove a 1-2 offering from Giles to left field, scoring Moustakas, Cheslor Cuthbert and Alex Gordon.

"Giles is kind of a go-get-em from the get-go," Merrifield said. "He throws a hundred with a banger slider. Just try to see the ball as early as you can and hope for a mistake. He made one on me, and I was able to put the bat on it and find a good spot."

Merrifield has hit safely in 20 of his last 21 games. Giles blew his second save in 18 opportunities.

"I let my team down," Giles said. "It's all on me. In my eyes, this team won today. My failure shouldn't overshadow what these guys did today. They did exactly what they needed to do. This is going to hurt for a little bit, all night."

The Astros' winning streak was the longest in the majors this season. They dropped to a major league-best 42-17 this season.

Mike Minor (3-1) pitched a scoreless inning for the Royals.

Moustakas also singled in a run during the eighth.

Carlos Beltran hit his 429th career home run in the Astros' four-run fourth, giving them the six-run advantage. Josh Reddick, who had three hits, and Carlos Correa had the other run-scoring hits in the inning.

Houston rookie starter David Paulino gave up three runs and eight hits over 5 2/3 innings and left with a 7-3 lead.