Mike Yastrzemski and Matt Chapman homered as the San Francisco Giants rallied to beat the Milwaukee Brewers 6-5 on Thursday to take three of four games in the series in San Francisco.

Yastrzemski hit a solo homer, finished with two RBIs and scored twice. Chapman hit his fifth homer of the season, a two-run shot, in the fifth inning.

San Francisco trailed 5-4 when Tyler Fitzgerald opened the eighth by drawing a walk from Tyler Alexander (1-2). Fitzgerald moved to third on a single by pinch-hitter Wilmer Flores and a groundout moved pinch-runner Christian Koss to second.

Yastrzemski hit a grounder to second baseman Brice Turang, who was playing in. Turang’s throw to the plate was high and Fitzgerald slid safely to tie the game at 5, with Koss moving to third.

Trevor Megill replaced Alexander and Willy Adames, a former Milwaukee shortstop, pulled a liner to left that was misplayed by Christian Yelich. Koss scored on the sacrifice fly and Adames reached on the Yelich error.

Reliever Tyler Rogers (2-0) struck out three in the eighth inning. Camilo Doval worked the ninth and earned his fifth save.

The Brewers had runners at first and second with two out in the ninth before Doval got Rhys Hoskins on a fly to center to end the game.

The Giants improved their major league-leading record against right-handed starters to 15-2.

The Giants host Texas and former manager Bruce Bochy today.

Royals 7-6, Rockies 4-2: Bobby Witt Jr. extended his hitting streak to a career-best 16 games with an RBI single in the fifth inning, and host Kansas City went on to beat Colorado to cap off a doubleheader and series sweep.

Salvador Perez had three hits and a pair of RBIs, and Vinnie Pasquantino, Michael Massey and Drew Waters also drove in runs, helping the Royals win their fourth consecutive game on the heels of a six-game losing streak.

The sweep left the Rockies at 4-20 — the worst start in club history. They also matched a franchise record with their 13th consecutive road loss.

Orioles 2, Nationals 1: Cade Povich limited Washington to a run in 6 2/3 innings, Ryan O’Hearn and Cedric Mullins had RBI singles in the fifth and visiting Baltimore ended a three-game losing streak.

Povich (1-2) allowed four hits. The left-hander struck out five and walked one.

Mullins has hit safely in six straight games and has seven hits in that span.

White Sox 3, Twins 0 (7): Lenyn Sosa and Michael Vargas homered as Chicago beat Minnesota in a game that was shortened to seven innings because of rain in Minneapolis.

The win salvaged the finale of the three-game series for Chicago and snapped a 14-game losing streak at Target Field, the longest road losing streak against any opponent in team history.

Twins third baseman Royce Lewis (JSerra High) will begin an injury rehab assignment today at Triple-A St. Paul.

Mariners 4, Red Sox 3: Bryan Woo scattered three hits over six innings, and visiting Seattle tagged Red Sox ace Garrett Crochet for four runs in the first two innings to beat Boston and win the three-game series.

Leo Rivas and J.P. Crawford each had a pair of hits for the Mariners, who have won 10 of their last 13 games. Woo (3-1) struck out eight while allowing two runs and one walk. Randy Arozarena had three walks.

Rays 7, Diamondbacks 4 (10): Christopher Morel hit a two-run homer in the 10th inning and Tampa Bay rallied to beat Arizona in Phoenix.

Arizona led 4-3 before Yandy Diaz hit a tying run-scoring single off Ryne Nelson in the ninth.