First, the Royals had to wipe out the Brewers' 3-1 lead in the ninth, and they didn't do that until there were two outs.
That's when Alcides Escobar's triple forced the game into extra innings. Facing Brewers closer John Axford, Eric Hosmer and Moustakas each drew walks, then both scored when Escobar pounded a drive into deep left-center field.
Escobar drew on his days with the Brewers to help him against Axford.
"I know those guys from Milwaukee, because I was there a long time and that guy, he likes to throw the fastball," Escobar said.
Axford was unhappy after his second straight subpar performance.
"Right now, in all honesty, it's kind of embarrassing on my part, because I don't know what's going on," Axford said. "I know I'm better than this."
Axford did strand Escobar on third to preserve the tie by striking out pinch-hitter Clint Robinson, but there was more trouble ahead for his bullpen mates.
Facing reliever Kameron Loe, Billy Butler opened the Royals' 11th with a single to center field. Hosmer walked and Jeff Francoeur singled to left, but not deep enough to get Butler home.
Now with the bases loaded and no outs, the Brewers replaced Loe with another right-hander, Jose Veras. They also implemented a five-man infield, bringing Ryan Braun in from left field as Moustakas came to the plate.
"I didn't really know what was going on," Moustakas said. "I wasn't really concerned about the infield. The only thing I was doing is I was going to hit a fly ball to the outfield. That's my focus right there."
None of it mattered, because Veras walked Moustakas on a 3-1 pitch. The victory, just the Royals' 10th in 30 home games, was in the books.
The Royals' bats have been slumbering, but Yost saw signs of a breakthrough in this game.
"We were down 2-1 and [Randy] Wolf was throwing a darn good game, but their defense was playing big," Yost said. "We scorched five balls right at guys that they made great plays on to keep us off the board. I knew we were swinging the bats good, we just had to find some holes and we finally did."
In each of their six previous games, the Royals had scored three runs or fewer, and lost four of them. Could this be the kind of victory that gets the offense going?
"There's no doubt," Butler said. "Everyone in here knows we've been struggling to score runs. The pitching staff's been great. Especially in June, we've had one of the better pitching staffs in baseball.
"We have to step up and help them out. It wasn't pretty tonight with the way we scored four, but we got the win and we have to feed off of it and score more runs for the pitching staff. If they keep pitching like this, we should be all right the rest of the year."
Yost was pleased with the way that left-hander Jonathan Sanchez, back after being out since May 7 with arm problems, pitched for five innings. He held the Brewers to one run, by virtue of four infield singles in the third.
"This was his best outing for me, by far, all year long," Yost said.
The Royals couldn't get much going against Wolf, the Brewers' lefty. They had a shot at breaking a 1-1 tie in the sixth when Butler, on first base with a single, tried to score on Francoeur's double to deep left-center field. It was a gamble, considering Butler's lack of speed, and he was thrown out at the plate.
"I was yelling, 'Keep him coming,'" Yost said. "They had to be dead on to be able to defend it and give them credit, they were."
Butler wasn't surprised to see third-base coach Eddie Rodriguez waving him home.
"Not with the way we've been playing. We've got to try to push for runs," Butler said. "I was going from whenever the ball was hit. I'm not the fastest guy, just a bad situation for me, I guess. I gave it my best effort."
The hit that seemed to snap the Royals to full alert was Escobar's booming triple.
"It's a big momentum boost for us," Hosmer said. "I don't think anyone was thinking about losing after that."
Last season, Yost was criticized for letting Escobar hit in similar crucial situations rather than using a pinch-hitter. But this year Escobar is hitting .292 and connecting with some big hits.
"I've done it too many times to say, 'I told you so,'" Yost said. "I know it works. It gives kids a chance to grow up a little bit and gives them a chance to produce later in their careers, and Escobar has surely been doing that."
Now, as Butler sees it, the Royals need some more Escobar-type hits to keep the momentum going.
"You've got to have somebody new step up each night," Butler said. "That's what good teams do. That's what it's going to take around here. We've got a lot of talent around here. Whoever is up in a big spot has got to get it done. Won't know who that is tomorrow, but we'll see."