SAN FRANCISCO — Josh Tomlin struck out five and pitched into the eighth inning to win back-to-back starts for the first time this year, and the Cleveland Indians capitalized on two costly errors to rally and beat the San Francisco Giants 5-3 on Monday night.

Tomlin (6-9) allowed six hits and three runs without walking a batter in 71/3 innings. Cleveland snapped a season-high four-game skid with its first victory against the Giants in the past seven tries.

Yan Gomes homered leading off the third for the Indians, who didn’t have to travel far for a much-needed change of scenery after being swept across the bay at Oakland during a weekend series.

San Francisco starter Matt Moore (3-10) hit an RBI single in the third before a wild throw did him in, and the Giants dropped their fourth consecutive home game. Moore became the first Giants starter to lose five consecutive home starts since Ryan Vogelsong in 2011.

Moore scooped up Bradley Zimmer’s chopper in the fifth and made a wild underhanded throw that sailed well over fill-in first baseman Jae-Gyun Hwang, allowing Giovanny Urshela to come home. Zimmer then scored on Michael Brantley’s tying single.

Hwang’s throwing error covering Brandon Guyer’s sacrifice bunt in the sixth allowed the go-ahead run by Jose Ramirez, aboard on a leadoff double.

Gorkys Hernandez hit an RBI double in the third for the Giants, who began a season-long 10-game homestand and played the first to start a stretch with 18 of the next 23 at AT&T Park.

On the play, Joe Panik was initially thrown out at home, but it went to replay review to determine whether Panik’s sliding left leg got beneath the tag by Gomes, the catcher. The call was overturned in 2 minutes, 13 seconds, and Panik had the tying run on Hernandez’s hit.

SELLOUT STREAK ENDS

The Giants’ sellout streak ended at an NL-record 530 games after attendance was 39,538.

The run dated back to 2010, the club’s first World Series title season here, and was second only to Boston’s 794.