The Kansas City Royals broke out of an extended run-scoring slump by getting to one of the toughest relievers in baseball.

They celebrated in the dugout after eighth-place hitter Adalberto Mondesi lined the first pitch from left-hander Josh Hader off the outfield wall for a long, two-run single with the bases loaded to take a 3-1 lead.

The hit was a turning point in a five-run seventh for the Royals, who held off the Milwaukee Brewers in the ninth for a 5-4 win on Wednesday.

"Score two runs and you can just kind of sense a sigh of relief from our offense, and then tacked on a couple more. It was good," manager Ned Yost said.

The Royals (25-55) scored more than four in a game for the first time since a 9-6 loss to the Angels on June 4. That 19-game stretch with four runs or fewer was the longest in the majors since the Baltimore Orioles went 21 straight in September 1992.

Danny Duffy (4-7) allowed five hits over six effective innings for the Royals, who split a two-game interleague series with the NL Central-leading Brewers.

The Royals called on Wily Peralta, a former Brewer, to close out the game after Brad Miller hit a three-run homer off reliever Tim Hill with nobody out in the ninth to get the Brewers within 5-4.

Eric Thames struck out before pinch-hitter Erik Kratz singled. Peralta then got Ryan Braun to bounce into a game-ending double play that was initially ruled as a fielder's choice before the call was overturned on review.

Peralta said he felt a little extra sense of satisfaction in turning away the Brewers for his second save.

"There's always a little bit of adrenaline going when you face your former team," the right-hander said.

Mike Moustakas opened the seventh with a solo shot off Brent Suter (8-5) to tie the game at 1-all. Moustakas and Whit Merrifield each had two hits and an RBI.

Kansas City, which was hitting .188 in June coming into the game, got to the hard-throwing Hader. He allowed all three runners he inherited to score.

Hader also gave up one earned run on his own, along with two hits in two-thirds of an inning.

"They jumped on the first pitch and we've seen that a lot lately, but he's been so effective that obviously multiple hits in an inning is something we haven't seen," manager Craig Counsell said. "They got him today."

FOR STARTERS

Royals: Duffy struck out seven and walked two. The left-hander has a 2.52 ERA over his past four starts.

TRAINER'S ROOM

Royals: RHP Justin Grimm was placed on the 10-day disabled list retroactive to June 24 with what they club said was right shoulder impingement syndrome. Grimm (1-3), who is making his second trip this year to the DL, would be eligible to return on July 4 against Cleveland. RHP Jason Adam was called up from Triple-A Omaha to replace Grimm in the bullpen. ... C Salvador Perez left the game with nobody out and two on in the top of the ninth after a foul ball off the bat of Brad Miller ricocheted off his upper right leg. He was replaced by Drew Butera.

UP NEXT

Royals: After a day off in Seattle, Ian Kennedy (1-7) opens a three-game series on Friday against the Mariners.