SAN FRANCISCO — Chris Stratton pitched a two-hitter for his first career shutout, Austin Slater backed him with a two-run single, and the San Francisco Giants snapped an 11-game losing streak by beating the Colorado Rockies 2-0 on Friday night.

The NL West-leading Rockies had their division lead trimmed to a half-game over the Los Angeles Dodgers, who won at St. Louis. Colorado had its seven-game winning streak against San Francisco snapped.

Stratton (10-9) struck out seven and walked two, throwing 114 pitches to finish the 2-hour, 20-minute game. He allowed only one baserunner to reach second with Trevor Story getting there in the second.

The right-hander has a career high in victories and became the Giants’ first pitcher with double-digit wins since 2016 when Johnny Cueto, Madison Bumgarner and Jeff Samardzija got there.

Stratton retired nine straight during one stretch, then his final 12 batters. He pitched the first Giants’ shutout since Samardzija on Aug. 28, 2017, against San Diego.

While ending the longest skid of Bruce Bochy’s managerial career — he had a nine-game losing streak with San Diego in 2003 — the Giants earned their first victory this month.

The Giants avoided what would have been just the fourth losing streak of 12 or more games in franchise history since 1883. They did so in 1944 with a 13-game skid and also in 1902 and 1900 — all of them while playing in New York.