Updated

Wily Peralta pitched seven innings of one-run ball and the Milwaukee Brewers avoided a four-game sweep against the Arizona Diamondbacks with a 5-1 victory.

Peralta (7-9), who was coming off a shutout against the Reds on Tuesday, gave up seven hits and a pair of walks while striking out eight in his outing. He has allowed just one run over his last three starts.

Logan Schafer hit a solo homer and knocked in two runs for the Brewers (38-56), who enter the All-Star break last in the NL Central. Carlos Gomez also drove in two runs and Martin Maldonado added an RBI.

"A lot of good things happened," said Brewers manager Ron Roenicke. "Wily looked good, we came out swinging the bats. Any time we can get three runs in early and we feel like we have enough pitching to keep him there, it should turn out well, and it did."

Miguel Montero hit a solo homer for the Diamondbacks (50-45), who sit first in the NL West at the break for the first time since 2008.

"It's good, we're in first place," said Diamondbacks manager Kirk Gibson. "We've had a lot of trials and tribulations but the team has hung in there well. We've stuck together well."

Starter Ian Kennedy(3-6) surrendered all five runs on nine hits and two walks over 6 1/3 innings in his seventh attempt to earn his 50th career win. His last victory came on June 1 against the Cubs.

Milwaukee battered Kennedy for four runs and six hits over the first two innings.

Norichika Aoki, Schafer and Jean Segura hit consecutive singles to start the game. Gomez followed with a single of his own, scoring two in the process. After Juan Francisco struck out, Maldonado grounded out, but scored Segura.

In the second, with men on the corners, Schafer's sacrifice bunt plated Jeff Bianchi.

Schafer delivered again in the fifth with a solo shot to right.

Arizona got on the board in the home half, thanks to a home run from Montero, but the offense remained inept for the remainder of the contest.

In the sixth, Gerardo Parra and Paul Goldschmidt hit back-to-back singles to start the frame. Aaron Hill struck out on a wild pitch, but both runners were able to advance. However, Jason Kubel struck out and Martin Prado grounded out to second.

Hill mustered a single off Francisco Rodriguez in the ninth but was forced out at second on a fielder's choice by Kubel. Prado lined out to left and Montero popped out to end the game.

Game Notes

The Diamondbacks had won six straight against the Brewers ... Milwaukee has a 56-55 edge all-time against Arizona ... The Brewers hit 3-for-11 with runners in scoring position while the Diamondbacks were 0-for-6 with RISP ... Segura went 3-for-3 with a walk. His 121 hits lead the National League ... The Diamondbacks have collected an extra-base hit in an MLB-best 79 straight games, the second-longest streak in franchise history.