PITTSBURGH (AP) – Jeff Locke followed consecutive horrible starts with 6 2/3 scoreless innings, Erik Kratz hit his first home run since 2014 and the Pittsburgh Pirates beat San Francisco 1-0 on Monday night, ending the Giants’ eight-game winning streak.

Locke (6-5) allowed five hits, no walks and struck out three, helping the Pirates to just their second win in 12 games. He had allowed 18 runs and 20 hits over 8 2/3 innings during his previous two outings.

Madison Bumgarner (8-3) was the tough-luck loser, allowing one run in eight innings while having his seven-game winning streak snapped. The left-hander had his 12th straight start allowing two earned runs or fewer and gave up five hits while striking out eight and walking two.

It was Bumgarner’s second complete game of the season and 12th of his career.

Kratz’s solo shot with two outs in fifth was his first since a two-homer game for the Kansas City Royals on Aug. 18, 2014 against the Minnesota Twins.

The veteran catcher had been hitless in 16 at-bats since the Pirates acquired him from the Los Angeles Angels for $20,000 on June 11 after Francisco Cervelli went on the disabled list with a broken left hand.

Mark Melancon pitched the ninth in his 400th career appearance for his 20th save in 21 chances.

Left fielder Angel Pagan leaped and appeared to make a spectacular catch at the top of fence on Kratz’s drive. However, the ball popped out of his glove when he crashed into the fence and fell into the first row of seats.

Locke was pulled after giving up a two-out double to Jarrett Parker in the seventh inning despite having thrown just 85 pitches. Locke also continued to be effective at home, winning for the fourth time in his last five starts and pitching at least 6 1/3 innings in each game.

Neftali Feliz got Bumgarner to ground out to end the threat and Tony Watson worked a scoreless eighth before Melancon finished.

TRAINER’S ROOM

Giants: 3B Matt Duffy (sore left Achilles tendon) sat out after playing in 188 consecutive games, which was the longest active streak in the major leagues. He underwent an MRI exam Monday. … CF Denard Span (stiff neck) got a night off but is expected to play Tuesday night.

Pirates: C Chris Stewart (sore left knee) sat out for the sixth time in eight games but said he should be able to play Tuesday. … RHP Ryan Vogelsong (facial fractures) said his vision has returned to 20-20 after being struck in the left eye by a pitch May 23 and hopes to be activated from the 60-day disabled list July 23, the first day he is eligible. … Pitching coach Ray Searage was sent home before the game with back spasms and a flare up of arthritis in his left wrist.

UP NEXT

Giants: RHP Johnny Cueto (10-1, 2.10 ERA) looks to extend his seven-game winning streak when he starts Tuesday night. He is 18-4 with a 2.13 ERA against the Pirates in 28 career starts.

Pirates: RHP Wilfredo Boscan (1-0, 2.92) is expected to be recalled from Triple-A Indianapolis to make his first major league start in place of RHP Juan Nicasio, who was placed on the restricted list Saturday. Boscan made five relief appearances for the Pirates earlier this season, including his major league debut May 19.