The Phillies beat the New York Mets 13-8 in their first game after the All-Star break, but scored a total of 14 in the next eight losses to drop out of contention.
"I think the trade deadline for our team has been a distraction," manager Charlie Manuel said. "I'll be glad when it's over."
The defending World Series champion Giants have lost five in a row and eight of nine. They came off a 3-7 homestand that left them last in the NL West.
Lannan (3-4) allowed three runs and seven hits in seven innings.
"We just have to do our job," Lannan said. "(Trade rumors) are part of the game. It's one of those things where you have to put it in the back of your mind and play. It's something you can't control."
Barry Zito (4-8) gave up four runs and five hits in 3 1/3 innings. The 2002 AL Cy Young Award winner is 0-7 with a 9.97 ERA on the road.
With Wednesday's non-waiver trade deadline approaching and neither team going anywhere, several players could be changing uniforms before the next pitch.
The possibility that Philadelphia deals Young increased when the team called up third baseman Cody Asche from Triple-A. Manuel said Asche will be in the lineup Wednesday, so Young will either play first base or move to a contender if he waives his no-trade clause.
"My family is a massive consideration in the decision-making process," Young said when asked where he'd like to go. "I'll just leave it at that."
Young almost certainly would welcome a return to the Rangers, where he spent his entire career before coming to the Phillies this season. His family still lives in Texas.
"Those things are between me and the Phillies," he said.
Asked if he expected to be traded, Young said: "I really don't know."
Young blamed the Phillies' troubles more on injuries than distractions.
"We do have the talent here, but a lot of guys have been banged-up," he said. "We have to take the last two months as a challenge. You have to take pride in the way you play the game."
Ruiz, All-Star lefty Cliff Lee and closer Jonathan Papelbon also could be traded by the Phillies. Lee and Papelbon are good friends, and they sat in the clubhouse chatting for a while after the game.
The Giants might consider moving two-time All-Star outfielder Hunter Pence and lefty Javier Lopez. Pence was traded from Houston to Philadelphia on July 29, 2011. The Phillies sent him to the Giants last July 31.
"I try not to pay much attention to that," Pence said. "Just focusing on what I can control. I'm trying to do my best to block it out."
Ruiz gave the Phillies a 4-2 lead in the fourth when he lined a shot just over the left field wall. Ruiz, an All-Star last year, had not homered in 176 at-bats since last Sept. 25 against Washington. He began the year with a 25-game suspension for using a banned amphetamine.
"I think Carlos showed last year the kind of hitter he can be," Manuel said. "He's missed some time and he's had a hard time getting back to where he was."
Pablo Sandoval drove in San Francisco's first two runs. He had a sacrifice fly in the first inning and his bloop single to right with two outs in the third drove in a run to tie it at 2.
Zito struggled through a 45-pitch first inning, allowing two runs. Delmon Young singled in a run with two outs and John Mayberry Jr. walked with the bases loaded.
Asche popped out to second pinch hitting in the seventh in his first major league at-bat. ... Reigning NL MVP Buster Posey was scratched because of an upset stomach. ... The Giants called up OF Roger Kieschnick and INF Brett Pill from Triple-A Fresno. ... San Francisco last won a road start by Zito in Game 5 of the NLCS last year against St. Louis. ... The Phillies are 15-6 at home since June 2. ... Dominic Chianese, who played Uncle Junior on HBO's "Sopranos," sang the national anthem. ... Chad Gaudin (4-2, 2.77) starts for the Giants vs. Kyle Kendrick (9-7, 3.96) on Wednesday night.