Updated

Aubrey Huff ended an 0-for-20 slump with a leadoff homer in the 10th inning and the San Francisco Giants snapped out of their offensive slumber, beating the New York Mets 7-6 on Tuesday night.

Nate Schierholtz homered for the Giants, who had lost eight of 11. The defending World Series champions, shut out three times in their previous six games, entered with the second-worst offense in the National League.

Javier Lopez (1-0) and Francisco Rodriguez escaped dicey jams in the ninth before Huff sent a 2-0 pitch from Taylor Buchholz (1-1) off the facing of the right-field overhang for his third home run.

Before that, Huff was in a 3-for-37 rut with one RBI during that stretch. He entered the game batting .190.

Brian Wilson got three outs to earn his ninth save in 10 chances.

Carlos Beltran hit a three-run homer and Ike Davis a two-run shot for the Mets off Ryan Vogelsong, a winner last week at Pittsburgh in his first major league start since 2004.

The 33-year-old journeyman was a brief respite for the Mets while facing Roy Halladay, Cliff Lee and Tim Lincecum in a four-game stretch.

New York had the bases loaded in the bottom of the ninth, but Josh Thole grounded into a 1-2-3 double play to end the inning.

The Giants entered ranked 15th out of 16 NL teams in runs (99) and on-base percentage (.295). Only the San Diego Padres were worse in those categories.

Before arriving in New York, they were shut out twice while losing three of four in Washington. San Francisco totaled four runs during the entire series and had scored 23 in their last 11 games.

Manager Bruce Bochy said the offense was "awful right now," so he tried to do something about it. Second baseman Freddy Sanchez and left fielder Pat Burrell were left out of a lineup that had little Mike Fontenot batting third. The team held a longer-than-usual hitters' meeting before the game, and Bochy himself threw knuckleballs to his players during batting practice to get them ready for Mets starter R.A. Dickey.

Apparently, it helped. San Francisco scored four times in the third to take a 4-3 lead, getting RBI singles from Vogelsong and Aaron Rowand before Fontenot's two-run single capped the rally.

The Giants were 3 for 42 with runners in scoring position during the first seven games of their road trip before getting three hits in those situations in the third inning alone Tuesday.

Schierholtz's second homer of the season put San Francisco up 6-5 in the sixth, but Jose Reyes tied it in the bottom half with a broken-bat RBI single over a drawn-in infield.

Reyes drew three walks, one intentional, after coming into the game with eight this season. He finished 3 for 3 with a stolen base.

Playing their first home game since President Barack Obama announced Sunday night that terrorist leader Osama bin Laden was killed by U.S. forces in Pakistan, the Mets donated 4,000 tickets to military members and their families.

New York wore special stars-and-stripes caps, and five members of the armed services threw out ceremonial first pitches, receiving a warm hand from the crowd of 32,288. Marine Corps veteran Sgt. Elizabeth Quinones sang "God Bless America" during the seventh-inning stretch, prompting brief chants of "U-S-A! U-S-A!"

Before the game, Mets manager Terry Collins said he thought all the servicemen in the stands would give his team "a lot of energy."

"I think there will be a lot of emotions tonight," he said.

But there were several "Let's Go Giants!" chants in the late innings.

NOTES: Giants 3B Pablo Sandoval had surgery on his broken right wrist and is still expected to miss four to six weeks. Sandoval will begin his rehabilitation in Arizona and join the team Friday in San Francisco. ... Collins said the Mets will re-evaluate whether the team's top pitching prospect, Jenrry Mejia, should be a starter or a reliever when he returns from a torn elbow ligament. Mejia has been told he needs surgery but is expected to get a second opinion. ... It was Beltran's first home run from the left side of the plate this season.