PITTSBURGH (AP) — Andrew McCutchen had four hits, including a homer, and scored three runs to lead the Pittsburgh Pirates to a 6-3 win over the San Francisco Giants on Saturday night.

Ryan Doumit also homered for the Pirates and had four RBIs, and Paul Maholm (4-4) allowed two runs over 6 1-3 innings to become the first Pirates starter to win a game in almost three weeks.

Maholm allowed six hits, did not walk a batter and had one strikeout. The Pirates have won seven of his past 11 starts.

Pittsburgh has won three of four since snapping a five-game losing streak.

Andres Torres had three hits, a run and an RBI for San Francisco, which had won six of its previous eight.

Todd Wellemeyer (3-5) was charged with six earned runs on nine hits with three walks and two strikeouts in three-plus innings, his shortest start this season.

The Giants nearly came all the way back from a 6-0 deficit when Freddy Sanchez almost had his third hit of the game — a potential bases-clearing double — with the bases loaded and two outs in the ninth. But Pirates left fielder Lastings Milledge made a diving catch on the warning track.

Playing in his 162nd career game one year and one day since being called up with hype that he could help rescue a moribund franchise, McCutchen led off four separate innings with hits: Two doubles, his seventh home run and a single.

He led off the game with a double and scored two batters later on a sacrifice fly by Doumit.

The Pirates batted around in the third, with the first five batters of the inning getting hits against Wellemeyer. McCutchen doubled and scored on a triple by Neil Walker, who reached base three times. Doumit followed with his sixth homer into the seats in right.

The next inning, McCutchen led off with a hit again — this one a high home run to left on a 1-1 pitch to tie him for the team lead in homers and make it 5-0.

Wellemeyer allowed Walker to reach on a walk and he eventually scored on a Doumit ground-rule double.

The Giants came back from a 4-0 deficit the previous night in Pittsburgh, and they scored twice in the sixth when Sanchez, a former Pirates player, hit an RBI double and scored on a groundout by pinch-hitter Matt Downs.

San Francisco added another run in the ninth with two hits and two walks against Pirates closer Octavio Dotel, including an RBI single by Torres.

NOTES: The most recent Pittsburgh starter to earn a victory was Zach Duke, who out-dueled Roy Halladay May 18 in Philadelphia. ... McCutchen's numbers for his first 162 games: .297 average, 19 home runs, 108 runs, 71 RBIs, 35 steals. ... The Giants lost for only the third time in 14 games against NL Central teams. ... San Francisco has scored during only three of their past 38 innings played on the road. ... A postgame fireworks and concert promotion led to the second sellout of the season at PNC Park.