Lorenzo Cain hit the second pitch of the game for a home run, and Jordan Lyles threw five strong innings in his Milwaukee debut Wednesday night, sending the Brewers to a 4-2 victory over the host Oakland Athletics in the second game of their three-game interleague series.

Lyles (6-7), who had been winless in eight starts for Pittsburgh dating to May 28 before being acquired by the Brewers in a trade Monday, checked the A's on three hits before leaving with a 3-1 lead. The right-hander walked two and struck out four.

Lyles was starting in place of left-hander Gio Gonzalez, who had to be scratched because of shoulder soreness.

The Brewers, who lost the series opener 3-2 in 10 innings on Tuesday night, never trailed after Cain took Brett Anderson (9-7) deep for his eighth homer of the season, his first leading off a game since last August against the Chicago Cubs.

Orlando Arcia scored on a Christian Yelich double in the third inning, Yasmani Grandal on a Mike Moustakas infield out in the fourth and pinch runner Ben Gamel on a Lou Trivino wild pitch in the eighth, as the Brewers managed to stay a step ahead of the A's.

Oakland's runs came in the third on a Matt Chapman sacrifice fly, which got the A's within 2-1, and on a Jurickson Profar pinch-hit double in the seventh that again made it a one-run game at 3-2.

In remaining winless in his last four starts, Anderson worked seven innings, allowing three runs and eight hits. He struck out three and did not issue a walk.

The Milwaukee bullpen limited the A's to one run over the final four innings, with Matt Albers, Jeremy Jeffress and Junior Guerra working an inning apiece before Josh Hader pitched a scoreless ninth for his 24th save.

Hader, who served up Matt Olson's walk-off home run in the 10th inning of the series opener, retired Marcus Semien — representing the potential game-tying run — on a pop fly to end the game.

Arcia and Ryan Braun collected two hits apiece for the Brewers, who snapped a two-game losing streak.

Profar and Chris Herrmann had two hits each for the A's, who fell to 3-3 on their nine-game homestand.

The Brewers out-hit the A's 9-7.