SAN FRANCISCO -- On a day the San Francisco Giants acquired Hunter Pence to bolster the middle of their lineup, they got a look at what a familiar face could do for their rotation.

Tim Lincecum. Remember him?

Lincecum gave up one run in seven innings as the Giants snapped their five-game losing streak with a 4-1 victory over the New York Mets on Tuesday night at AT&T Park.

"He had all his pitches going," Giants manager Bruce Bochy said. "He was under control. He threw quality strikes."

Lincecum spent the entire first half in a mysterious slump, but he has a 2.70 ERA in four starts since the All-Star break.

"He's been huge for us," Giants first baseman Brandon Belt said. "That's like a huge trade for us. Look back to the All-Star break or maybe before, you've seen the old Timmy come back. If he can keep doing a great job, it'll help us toward the end of the season and during the playoff run."

He was sharp for much of the night Tuesday. Lincecum started to wobble in the seventh, but he escaped a bases-loaded jam by striking out pinch hitter David Wright looking at a curveball. It was the last, and perhaps the best, of Lincecum's 112 pitches.

"I knew I wanted to go to it because I hadn't used it all that much," Lincecum said of the curveball. "That's kind of a freeze pitch. They hadn't seen it much all game, and that was my best one."

Bochy said that sequence was an example of Lincecum at his best.

"It's hard to throw a better pitch than he did that last at-bat," Bochy said. "When Timmy is good, he has a great knack, like all good pitchers, of making pitches when he has to, and he did, when the game was on the line."

The Giants, who will have Pence in uniform for Wednesday's game, still didn't do much offensively against Mets rookie Matt Harvey. In six innings against Harvey, the Giants had only four hits, and they struck out seven times. They scored three runs, but one came on a double play and the other two because of an error.

"He pitched very well," Mets manager Terry Collins said of Harvey. "He didn't have the command that he did the first time out. His changeup was very good today. He kept us in the ballgame."

The Giants added an insurance run on Marco Scutaro's RBI single in the eighth.

The San Francisco bullpen, which blew a two-run eighth-inning lead a night earlier, made this one stand. Jeremy Affeldt pitched two innings for his second save.

Harvey, a former first-round pick, had 11 strikeouts in his electric major league debut his previous time out.

The Mets scored an early run against Lincecum on Justin Turner's two-out RBI double in the second.

The Giants came back with two runs against Harvey in the bottom of the inning, but the rally came courtesy of a gift from shortstop Ruben Tejada. With the bases loaded and one out, Tejada was the pivot man for an easy, inning-ending double play, but he threw the ball away. Two runs scored.