SAN FRANCISCO -- Sergio Romo said it didn’t take long to recognize that Matt Cain, returning Friday after missing three starts with a strained hamstring, was seriously back.

"He throws that first pitch at 93 (mph), it’s like, OK, he’s here," Romo said. "Then all of a sudden we’re in the sixth with no hits.

"I don’t know if I could do that."

Cain didn’t get a decision in the Giants’ 4-2 win over the Mets, thanks to a mistake slider that Daniel Murphy hit for a two-run homer in the seventh, but it was hard to view his first start since he injured his hamstring May 21 in Colorado as anything but successful.

The right-hander retired the first 12 batters he faced before Curtis Granderson’s leadoff walk in the fifth and didn’t allow a hit until Ruben Tejada led off the sixth with an infield single. Both times, Cain promptly erased the runner by inducing a double play.

Cain’s only blemish came when Matt den Dekker led off the seventh with a double and Murphy hit a 1-0 slider for a homer to right-center to give the Mets a 2-1 lead. Cain then retired the next three hitters to complete seven innings for the fourth time this season, needing 96 pitches to do so.

"He was sharp," manager Bruce Bochy said. "All his pitches were crisp. He was in command there, then they threw out a couple good at-bats on him, but he settled down and finished that inning. That’s a great effort with the time that he’s missed."

Catcher Buster Posey said Cain’s fastball on Friday night "had as much life on it as I’ve seen in a while. And I think the encouraging thing is the off-speed wasn’t even as sharp as it can be, and he still went seven strong only giving up two."

Both hits Cain allowed in the seventh came on sliders, though Cain said the one he threw to den Dekker in a 1-2 count was a good pitch that den Dekker beat by slapping it down the left-field line. "Then the bad one to Murphy just kind of rolled in there," Cain said.

Otherwise, Cain too sounded encouraged by his first start back. He said he didn’t feel any discomfort in the hamstring, and that it helped that he learned he’d be coming off the DL Friday while in St. Louis, so he could go about the past few days by his normal between-starts routine.

Cain was not overpowering Friday -- he struck out three -- but he was economical and he worked quickly, throwing 10 pitches in the second inning, 11 in the third and nine in the fourth. He finished with just his third quality start this season in nine outings.

"When a guy’s pitching like that, it’s easy to stay in the game," second baseman Brandon Hicks said. "It was a lot of fun."

This recent DL stint was just the third of Cain’s career, and two have come this season -- not ideal for a pitcher with the reputation of a workhorse. Cain joked Friday night that, "Maybe I should’ve stayed (out)" with how well the Giants have been playing lately, but got serious when asked about returning to the mound.

"It felt great," he said. "It stinks when you’re sitting there and watching the guys play real well. You want to be a part of it and want to be able to help out."

Cain’s record -- he remains stuck at 1-3 heading into the second week of June -- suggests the erstwhile staff ace hasn’t done that to the extent he’d like this year. The Giants have won his last three starts, but they’re still just 4-5 this season when Cain takes the mound. Despite all that, Cain remains a respected and important figure in the Giants’ clubhouse, as Romo indicated after securing the win and his 19th save Friday with a scoreless ninth.

Said Romo: "He definitely proved why he’s one of our leaders today."

* Posey’s two-run homer off Carlos Torres in the eighth broke a 2-2 tie and snapped a 93-at-bat homerless streak for the former MVP. Posey hadn’t homered since May 3 in Atlanta, and hadn’t hit one out at AT&T Park since April 29 vs. San Diego.

In fact, Posey, a career .282 hitter at AT&T, has struggled mightily at home this season, as he entered Friday with a .196 average and four hits in his last 42 at-bats. Asked why that might be Friday night, Posey said: "Baseball’s weird."

Posey had been 11-for-63 before collecting three hits in four at-bats Friday, including a pair of singles off lefty starter Jonathon Niese. The home run came on a 1-0 slider that Torres left over the middle of the plate. Posey’s slugging percentage is still .419 -- lower than those of both Angel Pagan and Brandon Crawford -- but Bochy and Cain both said Posey’s recent at-bats have been encouraging.

"I think he’s been getting good swings off. The home runs haven’t been there, but he’s been hitting it hard," Bochy said. "He just hadn’t gotten the ball up in the air, and tonight he did on the home run."

Cain said it looked like Posey was "just missing pitches in Cincinnati, and he had a couple pitches today that maybe he wanted to drive a little farther. But he got some hits and took advantage of that one that finally hung there for him."

* Another encouraging night with the bat belonged to Hicks, who came in 3-for-his-last-29 and reached base three times, including a double and triple. He also walked and scored the tying run in the seventh, when he advanced to second on a wild pitch and scored on Brandon Crawford’s two-out single up the middle off Niese.

Hicks said he felt he was able to carry some adjustments from cage work into the game, including trying to stay on top of the ball better. "I’ve been getting under it a little bit," Hicks said, "so just making that minor adjustment."

Crawford also drove in Hicks after his fifth-inning triple with a sacrifice fly as the game’s first run, and his single in the seventh gave the Giants their majors-leading 123rd run this season with two outs.

"It’s hard to get better clutch hitting than what he did with that base hit up the middle," Bochy said. "We talk about this, we’re getting contributions from everyone throughout the lineup, and tonight those two picked us up. That’s one reason we’ve had success to this point -- it’s not one or two guys carrying the load."

Cain was asked about the depth of this year’s lineup and said he thinks it’s "definitely one of the best we’ve had in past years, even when we won (the World Series). These guys can hit from top to bottom, and it’s not always the guys in the middle of the lineup that are going to hurt you with power. The guys at the end can do it, too."

* Lest it be forgotten, the Giants have mounted their recent tear without the services of Brandon Belt, who had the pins removed from his fractured thumb Friday afternoon. Bochy said Belt will remain in a cast for another week, after which he’ll be able to start doing baseball activities.

"He’s still, I’d say, three weeks away, in that area," Bochy said. "We don’t have a target date, but it’s a big day for him to get those pins out."

Belt was in the clubhouse after the game -- and showed reporters a video he had taken of himself getting the pins removed. His immediate reaction to the extraction: "That was a lot better than I expected."

* The Giants, who keep rolling along, are the first team in the majors this season to 40 wins, and they reached that mark after 61 games. They didn’t record their 40th win last season until July 6.

The pitcher of record, incidentally, was reliever Jeremy Affeldt, who threw a scoreless eighth inning -- on his 35th birthday. According to the Giants, it was Affeldt’s first win on his birthday.

* The Giants made eight more picks on day two of the MLB Draft, including selecting right-hander Logan Webb of Rocklin High School in the fourth round (118th overall).

Webb, who also played quarterback for Rocklin High’s football team, had a 0.49 ERA with 73 strikeouts in 57 2/3 innings as a senior in 2014 and earned MVP honors for the Sierra Foothill League. He’s 17 years old and listed at 6-foot-2 and 195 pounds.

The Giants used their third-round pick on right fielder Dylan Davis out of Oregon State University. Davis, listed at 6-feet and 215 pounds, led the Pac-12 Conference in 2014 with 64 RBIs. Here’s the full list of the Giants’ draftees through the first 10 rounds:

1. Tyler Beede, RHP, Vanderbilt, 6-4, 215, R/R, born 5/23/1993

2. Aramis Garcia, C, Florida International, 6-2, 195, R/R, 1/12/1993

3. Dylan Davis, RF, Oregon State, 6-0, 215, R/R, 7/20/1993

4. Logan Webb, RHP, Rocklin HS, 6-2, 195, R/R, 11/18/1996

5. Samuel Coonrad, RHP, SIU Carbondale, 6-2, 190, R/R, 9/22/1992

6. Skyler Ewing, 1B, Rice, 6-1, 220, R/R, 8/22/1992

7. Seth Harrison, CF, Louisiana-Lafayette, 6-1, 195, R/R, 7/22/1992

8. Austin Slater, CF, Stanford, 6-2, 205, R/R, 12/13/1992

9. Stetson Woods, RHP, Liberty HS (CA), 6-8, 200, R/R, 1/15/1995

10. Matthew Gage, LHP, Siena College (NY), 6-4, 240, R/L, 2/11/1993

* It’s a matchup of seasoned right-handers in game two of the series Saturday, with the Giants sending Tim Hudson (6-2, 1.75) to the mound against the Mets’ Bartolo Colon (5-5, 4.52). First pitch at 7:05 p.m.