Brian Dozier's sacrifice fly in the 12th inning lifted the Los Angeles Dodgers to a 4-3 victory over the San Francisco Giants on Wednesday night, snapping a five-game losing streak.

The struggling Dodgers bullpen coughed up a 3-0 lead in the eighth when rookie Caleb Ferguson gave up a three-run homer to Andrew McCutchen.

More Images
Los Angeles Dodgers' Justin Turner, right, celebrates with Matt Kemp after scoring on a double by Manny Machado during the seventh inning of a baseball game against the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Brian Dozier's sacrifice fly in the 12th inning lifted the Los Angeles Dodgers to a 4-3 victory over the San Francisco Giants on Wednesday night, snapping a five-game losing streak.

Los Angeles Dodgers' Matt Kemp, right, breaks his bat as he hits a single while San Francisco Giants catcher Buster Posey and home plate umpire Stu Scheurwater watch during the fifth inning of a baseball game Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Left-hander Hyun-Jin Ryu, making his first start since suffering a serious groin injury on May 2, was brilliant in his return. He threw six scoreless innings, holding the Giants to three hits without allowing a walk and striking out six.

Los Angeles Lakers president Jeanie Buss, left, talks with former Los Angeles Dodgers manager Tommy Lasorda during the fourth inning of a baseball game between the Dodgers and the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

The Giants responded against the Dodgers' beleaguered bullpen in the eighth when McCutchen drilled his 14th homer.

Los Angeles Dodgers shortstop Manny Machado fields a ball hit by San Francisco Giants' Buster Posey during the fourth inning of a baseball game Wednesday, Aug. 15, 2018, in Los Angeles. Posey was thrown out at first on the play. (AP PhotoMark J. Terrill)

Yasmani Grandal led off the 12th with a double against Casey Kelly (0-1) and was singled to third before Dozier's flyball ended it.

Los Angeles Dodgers starting pitcher Hyun-Jin Ryu rubs up the ball before pitching during the first inning of the team's baseball game against the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Dodgers: Placed RHP Ross Stripling on the 10-day disabled list with two compressed discs in his lower back, retroactive to Friday. Stripling said he's had the problem since college. ... LHP Tony Cingrani (left shoulder strain) was transferred from the 10-day to the 60-day DL. ... RHP Daniel Hudson (right forearm strain) is scheduled to come off the DL on Friday. ... Closer Kenley Jansen (irregular heartbeat) threw a second bullpen session. He is scheduled to see his cardiologist on Monday. ... LHP Julio Urias (left shoulder surgery) was scheduled to throw two-plus innings in a rehab start Wednesday, but lasted only 1 1/3 innings.

San Francisco Giants' Andrew McCutchen celebrates after hitting a three-run home run during the eighth inning of the team's baseball game against the Los Angeles Dodgers on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Dodgers: RHP Walker Buehler (5-4, 3.32) is scheduled to start Friday in the opener of a three-game series in Seattle. Buehler has a 2.80 ERA as a starter, limiting opponents to a .211 batting average.

But Los Angeles held San Francisco scoreless over the four innings that followed, with Pedro Baez (4-3) throwing the final two innings to earn the win.

Los Angeles Dodgers' Justin Turner, right, celebrates with Matt Kemp after scoring on a double by Manny Machado during the seventh inning of a baseball game against the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Los Angeles Dodgers' Justin Turner, right, celebrates with Matt Kemp after scoring on a double by Manny Machado during the seventh inning of a baseball game against the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Left-hander Hyun-Jin Ryu, making his first start since suffering a serious groin injury on May 2, was brilliant in his return. He threw six scoreless innings, holding the Giants to three hits without allowing a walk and striking out six.

Los Angeles ended a scoreless game with a run in the sixth after Yasiel Puig led off with a double. Puig, ejected Tuesday after a scuffle with Giants catcher Nick Hundley, took third on a flyout and scored on pinch-hitter Joc Pederson's sacrifice fly.

The Dodgers added two more in the seventh against reliever Ray Black. Justin Turner walked and scored on Manny Machado's double. Matt Kemp singled in Machado to give Los Angeles a 3-0 lead.

Los Angeles Dodgers' Matt Kemp, right, breaks his bat as he hits a single while San Francisco Giants catcher Buster Posey and home plate umpire Stu Scheurwater watch during the fifth inning of a baseball game Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Los Angeles Dodgers' Matt Kemp, right, breaks his bat as he hits a single while San Francisco Giants catcher Buster Posey and home plate umpire Stu Scheurwater watch during the fifth inning of a baseball game Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

The Giants responded against the Dodgers' beleaguered bullpen in the eighth when McCutchen drilled his 14th homer.

It was the first time this season the Dodgers asked Ferguson to pitch in back-to-back games.

San Francisco starter Derek Holland went 4 2/3 innings, holding the Dodgers scoreless on six hits and four walks (two intentional), with seven strikeouts.

Los Angeles Lakers president Jeanie Buss, left, talks with former Los Angeles Dodgers manager Tommy Lasorda during the fourth inning of a baseball game between the Dodgers and the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Los Angeles Lakers president Jeanie Buss, left, talks with former Los Angeles Dodgers manager Tommy Lasorda during the fourth inning of a baseball game between the Dodgers and the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Yasmani Grandal led off the 12th with a double against Casey Kelly (0-1) and was singled to third before Dozier's flyball ended it.

TRAINER'S ROOM

Giants: SS Brandon Crawford returned to the lineup after sitting out one game in the concussion protocol. ... 1B Brandon Belt (hyperextended knee) returned to the lineup. He was activated Tuesday, entered the game in the eighth when Hundley was ejected and scored the winning run on a close play at the plate. ... RHP Jeff Samardzija (right shoulder inflammation) threw a 30-pitch simulated game Tuesday and is scheduled to throw to hitters Friday before beginning a rehab assignment.

Los Angeles Dodgers shortstop Manny Machado fields a ball hit by San Francisco Giants' Buster Posey during the fourth inning of a baseball game Wednesday, Aug. 15, 2018, in Los Angeles. Posey was thrown out at first on the play. (AP PhotoMark J. Terrill)

Los Angeles Dodgers shortstop Manny Machado fields a ball hit by San Francisco Giants' Buster Posey during the fourth inning of a baseball game Wednesday, Aug. 15, 2018, in Los Angeles. Posey was thrown out at first on the play. (AP PhotoMark J. Terrill)

Dodgers: Placed RHP Ross Stripling on the 10-day disabled list with two compressed discs in his lower back, retroactive to Friday. Stripling said he's had the problem since college. ... LHP Tony Cingrani (left shoulder strain) was transferred from the 10-day to the 60-day DL. ... RHP Daniel Hudson (right forearm strain) is scheduled to come off the DL on Friday. ... Closer Kenley Jansen (irregular heartbeat) threw a second bullpen session. He is scheduled to see his cardiologist on Monday. ... LHP Julio Urias (left shoulder surgery) was scheduled to throw two-plus innings in a rehab start Wednesday, but lasted only 1 1/3 innings.

UP NEXT

Giants: RHP Dereck Rodriguez (6-1, 2.25 ERA) is scheduled to start Friday when the Giants open a three-game series against the Reds in Cincinnati. The Giants are 9-3 in his previous 12 starts.

Los Angeles Dodgers starting pitcher Hyun-Jin Ryu rubs up the ball before pitching during the first inning of the team's baseball game against the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Los Angeles Dodgers starting pitcher Hyun-Jin Ryu rubs up the ball before pitching during the first inning of the team's baseball game against the San Francisco Giants on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

Dodgers: RHP Walker Buehler (5-4, 3.32) is scheduled to start Friday in the opener of a three-game series in Seattle. Buehler has a 2.80 ERA as a starter, limiting opponents to a .211 batting average.

More AP baseball: https://apnews.com/tag/MLBbaseball and https://twitter.com/AP_Sports

San Francisco Giants' Andrew McCutchen celebrates after hitting a three-run home run during the eighth inning of the team's baseball game against the Los Angeles Dodgers on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)

San Francisco Giants' Andrew McCutchen celebrates after hitting a three-run home run during the eighth inning of the team's baseball game against the Los Angeles Dodgers on Wednesday, Aug. 15, 2018, in Los Angeles. (AP PhotoMark J. Terrill)