LOS ANGELES -- After being swept in a three-game series in San Francisco over the weekend, the Milwaukee Brewers opened a four-game set with the Los Angeles Dodgers on a high note Thursday night.

Jonathan Villar hit the go-ahead home run in the ninth inning and the Brewers snapped a three-game losing streak with an 8-6 victory over the Dodgers on before 44,183 at Dodger Stadium.

"I'm happy for the home run and the team win today," Villar said.

Villar, who went 2-for-5 with two RBIs, a stolen base and his sixth home run, drilled a two-run blast over the center-field wall off reliever Pedro Baez (0-2) -- breaking a 6-6 tie -- to lift the Brewers (31-36), winners of 14 of their last 20 games at Dodger Stadium.

"It was a fun game on our end," Brewers manager Craig Counsell said. "But it was an interesting game, good game. A lot of big pitches, lot of big plays. (Villar) really got that ball. It was a very well hit ball."

Tyler Thornburg (3-1) set the Dodgers down in order in the eight for the win. Jeremy Jeffress pitched a scoreless ninth before striking out Corey Seager with the bases loaded for his 19th save.

Trayce Thompson homered for the Dodgers (35-33).

Howie Kendrick's RBI single scored Thompson and Joc Pederson's run-scoring hit scored Kendrick to spark a three-run rally for Los Angeles in the sixth. Justin Turner's sacrifice fly to left scored Pederson and knotted the score at 6, but the Dodgers needed a review to confirm it.

Yasmani Grandal attempted to advance to second on Turner's fly ball. However, left fielder Ryan Braun threw out Grandal just as Pederson touched home plate.

"Those plays are out of your hands as a manager when someone is making the call 3,000 miles away," Counsell said, referring to New York, where the review decisions are made.

Grandal's gaffe initiated a heated exchange between him and Turner in the Dodgers' dugout.

"It was just one of those things where (Turner) thought 'Yaz' should've went back to first and not continued and made that play as close as it was," Dodgers manager Dave Roberts said. "Yaz would tell you, as the ball goes into second base he's gotta stop.

Scott Kazmir lasted four innings despite striking out eight, including the last four batters he faced. Kazmir gave up three runs on five hits with two walks. Kazmir yielded to reliever Casey Fien, who served up homers to Aaron Hill and Chris Carter in a three-run fifth.

"It's on me. I put my team in a bad hole," Kazmir said.

Brewers starter Junior Guerra served up five runs on five hits with four strikeouts and a walk in 5 1/3 innings. Guerra also hit a batter.

The Brewers plated three runs in the third off Kazmir. Villar led off the inning with an infield single followed by a walk to Hill. After a double steal put runners at second and third, Jonathan Lucroy laced a two-run single to right for a 2-0 Milwaukee advantage with one out. Lucroy came home on a sacrifice fly by Hernan Perez.

However, Thompson's three-run shot -- his 11th long ball this season -- to center in the bottom of the frame knotted the score 3-3.

Hill put the Brewers back on top, taking Fien deep into the left-field bleachers for a solo blast and a 4-3 lead. For Hill, it was his seventh homer this season. He also tagged Fien for his first earned run in eight innings.

After Ryan Braun reached on an infield single, Carter smoked a line drive over the wall in right-center for a two-run homer and a three-run Brewers' cushion. It was the 18th home run of the season for Carter.

But it was Villar who delivered the game-winner.

"That was clutch for us. He's been real good for us all year," Carter said of his teammate.

NOTES: A moment of silence was held before the game for victims of Sunday's shooting in an Orlando nightclub, where 49 people were killed. ... Dodgers RHP Kenta Maeda, who took a line drive off his right leg Tuesday against the Arizona Diamondbacks, remains on schedule to start Sunday. ... Dodgers INF Justin Turner was not in the starting lineup. Howie Kendrick started as 3B. ... Brewers OF Ryan Braun, a native of nearby Mission Hills, Calif., had hit safely in 18 of his 22 career games at Dodger Stadium. ... Milwaukee closer Jeremy Jeffress had not allowed a run or a walk on the road this season heading into the game. ... Los Angeles signed first-round pick Gavin Lux. RHP Zach Davies (5-3, 3.88 ERA) faces Dodgers LHP Julio Urias (0-2, 5.82 ERA) on Friday.