SAN FRANCISCO -- Pittsburgh Pirates right-hander Vance Worley took an early cushion and ran with it Monday night, pitching his first career shutout in a wire-to-wire, 5-0 victory over the San Francisco Giants in the opener of a three-game series.

Left fielder Josh Harrison walked and scored in a four-run first inning, then homered in the second, highlighting a seven-hit Pirates attack that produced a second consecutive win and a seventh in 10 games since the All-Star break.

The Pirates, who scored all their runs in the first two innings, are 16-7 against the National League West this season.

Pittsburgh's early barrage came at the expense of Giants ace left-hander Madison Bumgarner (12-8), who failed in his attempt to become the major league's second 13-game winner. The loss was the fifth in a row for the Giants, who were coming off a three-game home sweep at the hands of the Los Angeles Dodgers.

The defeat dropped the Giants (57-49) into a tie with the St. Louis Cardinals (56-48) for the second National League wild-card spot, with the Pirates (56-49) now just a half-game behind.

Worley (4-1), who was coming off a 12-7 home win over the Dodgers, was perfect for four innings against the Giants and faced the minimum for seven innings. The 26-year-old allowed only four hits, the first three of which were singles, and one walk. He struck out three.

The complete game was the second of Worley's career. He threw 100 pitches.

The first three baserunners Worley allowed -- singles by third baseman Pablo Sandoval in the fifth and center fielder Gregor Blanco in the sixth, and a walk to second baseman Joe Panik in the seventh -- were all erased on the bases, Sandoval and Panik on double plays, Blanco on a steal attempt.

Sandoval also singled in the eighth, giving him two of San Francisco's four hits, and right fielder Hunter Pence tripled in the ninth.

Harrison and shortstop Jordy Mercer had two hits apiece for the Pirates.

Bumgarner threw 22 pitches before recording his first out in the fateful first inning, and even that pitch cost him a run.

The Pirates loaded the bases with none out in the first on a single by Mercer sandwiched between walks to Harrison and center fielder Andrew McCutchen. First baseman Gaby Sanchez's sacrifice fly on Bumgarner's 22nd pitch made it 1-0.

After second baseman Neil Walker singled in Mercer to make it 2-0, Bumgarner hurt his own cause by throwing low to second base after having McCutchen picked off. The All-Star scored one pitch later when catcher Russell Martin grounded an RBI single to center field for a 3-0 lead.

Right fielder Gregory Polanco's sacrifice fly, the Pirates' second of the night, made it 4-0 before Bumgarner retired third baseman Brent Morel to end the inning on his 42nd pitch, the most he ever threw in one inning.

Harrison's home run came with one out in the second, a solo shot to left that was his seventh of the season.

Bumgarner retired eight of the nine batters he faced after the homer, then left trailing 4-0 after completing four innings. He gave up five runs on six hits and two walks in his shortest stint since Opening Day. He struck out a season-low two.

NOTES: The Pirates were facing a left-handed starting pitcher for the eighth time in 10 games since the All-Star break. They will face only one more lefty (Arizona's Vidal Nuno) in the final six games of their Western road trip. ... Pirates RHP Gerrit Cole (strained right lat muscle) threw five scoreless innings Monday in a rehab start for Triple-A Indianapolis. Cole allowed five hits and three walks, and he struck out seven. ... Giants 1B Brandon Belt passed his concussion test Monday and was cleared to take batting practice Tuesday. If all goes well, Belt could be activated by the end of the week, Giants manager Bruce Bochy said. ... The Giants announced a number change before the game. OF Tyler Colvin switched from No. 10 to No. 21 so that INF Tony Abreu could return to No. 10, the number he wore last season with the Giants. Abreu wore No. 21 since being promoted from Triple-A Fresno on Friday.