SAN FRANCISCO — Madison Bumgarner allowed one run over five innings for his first win of the season, and the San Francisco Giants beat the Pittsburgh Pirates 11-3 on Tuesday night.

Eduardo Nunez drove in two runs in his final game with San Francisco as he was traded to Boston for two minor leaguers.

The veteran infielder was pulled in the fifth inning and was later seen on television shaking hands with several teammates in the Giants’ clubhouse.

The deal was announced a few minutes after the final out.

Bumgarner also singled and scored, Buster Posey had three hits and an RBI and Joe Panik added a bases-loaded triple as struggling San Francisco won for only the fifth time in 16 games.

Josh Harrison singled twice for the Pirates, who fell behind 9-0 and couldn’t recover. Pittsburgh stranded seven runners in the first five innings, including four in scoring position.

Making his third start since coming off the disabled list after nearly three months following a dirt bike accident in Colorado on April 20, Bumgarner (1-4) was mostly sharp while quieting a potent Pittsburgh lineup and ending the Pirates’ seven-game winning streak at AT&T Park.

Three years after pitching a complete game to beat Pittsburgh in the National League wild-card game on his way to winning the 2014 World Series MVP, Bumgarner pitched out of a pair of early jams, allowed six hits and had four strikeouts.

It’s the first win by a Giants starting pitcher since July 5.

Jameson Taillon (6-4) took the loss, giving up 10 runs in three innings.

UMPIRE GOES DOWN

Posey lined a single that hit second base umpire Ed Hickox in the foot and knocked him down in the fifth inning.

Hickox slowly got to his feet and was attended to by a member of the Giants medical staff but remained in the game.

TRAINER’S ROOM

Giants: RHP Johnny Cueto may need to make a rehab start before rejoining the rotation. Cueto has been hindered by blisters on multiple fingers of his pitching hand, an issue that has lingered for much of the past month. The right-hander played catch from 105 feet before the game.

Pablo Sandoval moved from Single-A San Jose to Triple-A Sacramento as he continues to try to work his way back into the big leagues.

RHP Chris Stratton was recalled from Sacramento and IF Orlando Calixte was optioned down.