LOS ANGELES — Last season, the Dodgers fell behind and rarely recovered. This season, they have 24 comeback victories, finding ways to climb out of holes with timely hitting.

Adrian Gonzalez hit a two-run homer to put the Dodgers ahead in the eighth, and the NL West leaders beat the last-place Milwaukee Brewers 4-3 on Sunday for their fifth victory when trailing after seven innings.

"You hope it says something about the character of your club," manager Don Mattingly said.

The Dodgers took two out of three from the Brewers to go into the All-Star break with a 51-39 record.

"A group of guys that knows how to put good at-bats together over and over again," Justin Turner said in explaining the rally.

Pedro Baez (2-1) got the victory with a strikeout in one inning of relief. Kenley Jansen pitched the ninth to earn his 16th save in 17 chances, including his last nine since June 12.

Howie Kendrick singled leading off the eighth on his 32nd birthday and advanced to second after center fielder Carlos Gomez misplayed the ball for an error. Gonzalez followed with his 18th homer on an 0-2 slider from Will Smith (4-1), giving the Dodgers a 4-3 lead.

"You can't do that to a guy like that. He's a big strong guy," Smith said. "There's a reason why he's been an established hitter for so long. It's tough to go into the All-Star break with a bad taste in your mouth. You've got to get the job done, and I didn't do it."

Gonzalez was hitless in his first three at-bats Sunday, but five of his seven hits during the 10-game homestand were homers. He batted just .200 during that stretch.

"At least if I'm going to get very little hits they're homers," he said.

Smith gave up one run and two hits in 1/3 of an inning of relief.

The Dodgers closed to 3-2 in the fifth on A.J. Ellis' leadoff homer, his second in as many games.

Turner went 3 for 4 after coming in 0 for 10 in his last three games. Yasiel Puig, an All-Star a year ago as a rookie, saw his offensive woes continue, going hitless in four at-bats with two strikeouts.

The Brewers' Hernan Perez snapped a 1-1 tie leading off the third when he homered for the first time in his career on the first pitch from Brett Anderson. Perez's fielder's choice grounder in the fourth made it 3-1.

"They were extremely aggressive. They were swinging," said Ellis, who was behind the plate for the Dodgers. "I don't know if it was their goal to get to the All-Star game as quickly as possible."

Ryan Braun, who became a six-time All-Star in replacing injured Cardinals outfielder Matt Holliday on Sunday, homered with two outs in the first.

"It's a really difficult thing to accomplish, to make an All-Star team," Braun said. "It's an unfortunate way to get in. You never want to see anybody else get hurt."

Anderson gave up three runs and eight hits in seven innings. The left-hander struck out three and walked none while getting 11 groundball outs in facing the Brewers for the first time in his career.

Milwaukee starter Kyle Lohse allowed two runs and four hits in five innings. He struck out six and walked none.

BLOWN LEAD

The Brewers lost for the first time this season when leading after seven innings, dropping to 30-1. They fell to 11-11 in one-run games.

QUOTE OF THE DAY

"The fact that Clayton is a substitute is kind of asinine. He should have been there from the beginning." — Anderson on Kershaw making the NL All-Star roster as a sub for Max Scherzer.

UP NEXT

Brewers: They resume after the All-Star break with a five-game series at home, starting Friday against Pittsburgh. RHP Mike Fiers (4-7) will start. Milwaukee is 9-9 in his starts, including wins in each of his last four outings.

Dodgers: They hit the road after the break for a 10-game trip, starting Friday at NL East-leading Washington.

This story has been corrected to show Kershaw is a sub for Max Scherzer, instead of Matt Holliday.