"You want to pitch good every time out, whether it's your first (start) or your last," said Wells, who hadn't won since Oct. 1 of last season. "But you take the approach that you try to pitch well every time out and whatever happens, happens. I don't feel like I'm necessarily in a situation where this might be my last start, but you ever know."
Wells (1-5), who missed almost three months to start this season due to March surgery to repair a blocked artery in his pitching arm, tossed seven-plus shutout innings, allowing five hits while walking three and striking out three. He will be a free agent at the end of the season.
"He's a really good pitcher when he throws strikes early in the count," Pirates manager Jim Tracy said. "He was terrific tonight, very challenging with his fastball."
Barry Bonds went 0-for-4 for the Giants, who have lost a season-high five in a row -- by a combined eight runs. Bonds, who played with the Pirates from 1986-92 and won two National League Most Valuable Player awards, was greeted with a mixture of cheers and boos each time he came up -- about two-thirds boos. The Pirates have not had a winning season since his departure after the 1992 National League Championship Series.
Bonds flied out to left with two outs in the eighth - an inning in which the Giants had the bases loaded and nobody out.
The Giants had runners on second and third with nobody out in the ninth, but Mike Gonzalez promptly struck out the side for his 17th save in 17 chances.
"It's frustrating when it comes down to that. We're not getting blown out. We are right there."
The Pirates matched a season-high by winning their third consecutive game.
Freddy Sanchez had an RBI single and Jose Castillo an RBI double for the Pirates, whose only other three-game winning streak this season was against the Giants. Pittsburgh took the final three of a four-game series June 8-11 in San Francisco.
"I just kept trying to do what I wanted to do and I couldn't quite stick the ball in the spot I wanted to get it in," Schmidt said. "That makes it frustrating. I think every mistake I made they hit -- which is what they're supposed to do. Sometimes you make a mistake and they pop it up. But tonight it didn't happen."
Schmidt was dominant well into the sixth inning. The first Pirates' hitter of the game -- Nate McLouth -- singled to center off Schmidt (7-7), but the ex-Pirate retired the next 17 batters he faced before McLouth singled to left with two outs in the sixth.
Innocent enough, until consecutive singles followed by Jack Wilson and Sanchez. Sanchez's to left scored McLouth and Pittsburgh took a 1-0 lead.
"To put together three singles in a row against a guy like (Schmidt)," McLouth said. "You scratch out a run any way you can against somebody like that."
Schmidt started to unravel at that point, walking the next two batters on 11 pitches. Sean Casey was credited with an RBI when Wilson scored on his walk to make it 2-0.
"It seemed like ... he had tremendous stuff and he just kind of lost it," Giants manager Felipe Alou said.
Ronny Paulino singled to lead off the seventh and when Castillo, hitless in his last 11 at-bats, followed with a double into the gap in left-center, Schmidt's night was over.
"There was a great job tonight of table-setting by Nate and Jack," Tracy said. "And a great job of clutch hitting by Freddy and Jose."
Schmidt won his previous start Saturday against San Diego but had not won before that since June 6. Heading into Friday's game, he was 4-1 with a 2.08 ERA against his former team.
Wells' ERA was over 17.00 after allowing five first-inning runs to the New York Mets in his fourth start of the season July 5. But since then, the righthander has allowed only four runs in 24 2/3 innings.
"You see the last couple outings, he's been great," Gonzalez said. "I'm excited for Kip. He's throwing the ball well and looks good. I hadn't seen that in a while. I knew I needed to get out there in the ninth and get it done for Kip."
The Pirates' starting pitcher has worked at least six innings in nine of the last 12 games. ... Giants' starters have worked at least six innings in 73 of 103 games this season. ... The game drew 38,092 -- the Pirates third sellout of the season.