Updated

On a night the San Francisco Giants lost a game off their NL West lead, they acquired veteran infielder Marco Scutaro from the Colorado Rockies.

Hanley Ramirez hit a two-run homer in the 10th inning and the Los Angeles Dodgers beat San Francisco 5-3 on Friday night in a matchup of the top two teams in the NL West.

Scutaro, who will bolster San Francisco's infield, was hitting .271 with four home runs and 30 RBIs in 95 games for the Rockies.

"It's no secret we were looking for depth and experience," Giants general manager Brian Sabean said. "This guy is a starting player on both sides of the bag."

Scutaro will also help in the wake of Pablo Sandoval's hamstring injury. The Giants could make a few moves on Saturday with Scutaro's expected arrival, and the availability of Aubrey Huff.

Ryan Theriot played second base in Friday night's loss.

"Pablo's situation is pending so our roster is in a state of flux," Sabean said. "I don't think this will threaten Theriot. We just needed depth."

Scutaro joins his sixth major league team. He made his major league debut with the New York Mets in 2002. The Giants sent minor league infielder Charlie Culberson to Colorado to obtain Scutaro.

Culberson was hitting .236 with 10 home runs and 53 RBIs in his first year at Triple-A. He played in six games with the Giants this year, hitting .136 with one RBI.

The deal was announced after the Rockies, who are 37-61 and have the second-worst record in the National League, lost at home 3-0 to the Cincinnati Reds. Scutaro played the entire game and went 1 for 4.

"I've never been traded before during the season. I really had fun here," said Scutaro, whom Colorado acquired on Jan. 11 from the Boston Red Sox. "I really liked it here. Unfortunately, the season didn't go the way we expected in the beginning. That's the way baseball is. It's a business and I get to go to a first-place team. It's kind of nice because all the work you put in the offseason is to try and get a chance to play in the playoffs. I think I'm going to have that kind of opportunity with that team."

Scutaro was one of several veterans that Rockies general manager Dan O'Dowd acquired in the offseason to change the clubhouse mix. Scutaro, 36, has roughly $2 million remaining on his $6 million contract and can be a free agent after the season.

"I'm going to be a free agent and hopefully have the opportunity to come back here," Scutaro said. "I think the team is going to be good pretty soon. We'll see what happens."

It's unlikely Scutaro figures in the Rockies' plans for 2013, particularly with the arrival of impressive rookie Josh Rutledge, who is hitting .347 in 13 games with one homer and six RBIs.

The 23-year-old Rutledge has been playing shortstop because Troy Tulowitzki has been sidelined. He is expected to move to second base when he returns in August and is likely to play there next season.

Scutaro said he had no idea Friday that he would be traded until given the news after the game. He said he knows fellow Venezuelans Sandoval and Gregor Blanco on the Giants.

"I guess I just have to go there and find some friends," Scutaro said.

The Giants will visit Colorado for a three-game series beginning next Friday, which will be three days after the July 31 trade deadline.

"They should have waited for a week," Scutaro said of the deal, "so I don't have to travel."

Matt Cain allowed three runs and nine hits over seven innings. The All-Star right-hander, who struck out two and didn't walk anyone, has only one win over his last six starts and was on the hook for the loss until San Francisco scored twice in the eighth.

Melky Cabrera singled and went to third on Angel Pagan's one-out double. Brandon Belt followed with his third hit, a looping single to center that drove in two and tied it at 3.

NOTES: Giants C Hector Sanchez (left knee sprain) played seven innings for Triple-A Fresno and might see time at first base before being activated from the DL. ... A fan ran onto the field and made it to home plate before being taken away by security in the middle of the fifth inning. ... Dodgers RHP Chad Billingsley (5-9) faces LHP Barry Zito (8-6) in Saturday's game, which was originally scheduled as a night game before being changed to 1:05 p.m. for television.