In his first start at Yankee Stadium, Tim Lincecum was lifted a few pitches before the decisive blow.
Alex Rodriguez set a major league record with his 24th career grand slam, passing Lou Gehrig with a tiebreaking shot in the seventh inning that sent the New York Yankees to a 5-1 victory over the San Francisco Giants on Friday night.
A-Rod's drive off reliever George Kontos helped CC Sabathia beat Lincecum (10-14) in a matchup of former Cy Young Award winners having subpar seasons.
"Just tough to watch and tough to put somebody in that kind of situation," Lincecum said. "Just wasted a lot of pitches that inning, didn't attack the zone as much as the previous six, and I felt like I could've gotten out of that better than what happened."
With the score tied at 1, Eduardo Nunez grounded a slow single through the right side to start the seventh. Second baseman Joaquin Arias tweaked his hamstring when he broke for the ball and came out of the game the following inning.
"Bad luck for Timmy," manager Bruce Bochy said. "Joaquin would've had it."
Lincecum (10-14) hit Brendan Ryan with a pitch and walked Ichiro Suzuki with two outs, loading the bases and ending the right-hander's night after 121 pitches.
Rodriguez, hampered by a sore leg lately, reached out and lofted a 2-1 pitch from Kontos toward the hitter-friendly dimensions in right field for his 654th career homer and seventh this season.
The hit snapped a 1-for-25 slide for A-Rod, who returned Aug. 5 from hip surgery.
"I went back and looked at the pitch and I thought it was a pretty good pitch, little bit off the plate," Kontos said. "He might've just been leaning over looking for something and in this ballpark, with the guy as strong as he is, you flip it out there and put some backspin on it, the ball just tends to go to right field there.
"It was just one of those days where you get beat even if you throw a good pitch," Kontos added.
Lincecum, who had won four straight decisions, was looking for his first five-game winning streak since early in the 2010 season. He was charged with four runs and five hits in 6 2-3 innings.
"He pitched great," Bochy said. "It's some tough luck there in that last inning."
Rookie outfielder Juan Perez, back home in the Bronx, hit an RBI double. The defending World Series champions have spent all week in New York — they took two of three from the Mets at Citi Field, where a large throng of vocal San Francisco fans made them feel right at home.
Giants rooters came out in the Bronx, too, easy to spot in their orange or black jerseys. An audible chant of "Let's go Giants!" quickly drew boos from Yankees fans in the crowd of 41,734.
"There's a lot of Giants fans here. I noticed that. They travel well," Rodriguez said.
Plenty were surely there to see Perez, who is having a big week in his first trip home as a major leaguer. He went 3 for 3 with an RBI single in Thursday's 2-1 victory over the Mets, then doubled his first two times up Friday — including one off the left-field fence.
Perez said he left 12 tickets for family and friends, but plenty of others bought their own. His father was unable to attend Thursday's game in Queens because he was working, but Perez expected him in the stands at Yankee Stadium.
The Yankees won for the second time in seven games as they cling to faint playoff hopes. New York, which has eight games remaining, began the day 3½ behind Tampa Bay and Texas for the second AL wild card — with three other teams in between.
Alfonso Soriano also homered to the short porch in right and New York opened its final homestand with a much-needed victory, hours after pitcher Andy Pettitte announced his plans to retire (again) following this season.
Pettitte, who stepped off the mound for a year before returning in 2012, is scheduled to start the series finale Sunday — the same day the Yankees will honor retiring closer Mariano Rivera in a pregame ceremony.
Sabathia (14-13) was pulled after a leadoff single in the eighth and walked off to a warm ovation. David Robertson got Perez to ground into a double play, and Rivera worked a perfect ninth.
NOTES: Giants CF Angel Pagan was rested in favor of Perez. Bochy said he expects Pagan to be able to start in center on Saturday. Pagan had left hamstring surgery this season and missed 82 games. ... DH Buster Posey singled in the sixth to end a 1-for-23 skid on the road trip. Bochy said Posey will catch the remaining two games in the series. ... Bochy said it was his first trip to the new Yankee Stadium and he planned to get out to Monument Park later in the series. ... Bochy said he wasn't sure how long Arias might be out. "I think it's mild but we'll know more tomorrow," he said. ... The Giants dropped to 5-13 in interleague play.