Bruce Gradkowski and David Carr left no doubt about who the backup quarterbacks will be on their teams.

Gradkowski threw for 202 yards and two touchdowns after Jason Campbell left with an injury for the Oakland Raiders, and David Carr led a late touchdown drive that gave the San Francisco 49ers a 28-24 victory Saturday night in the annual Battle of the Bay.

Campbell left the game in the second quarter after being hurt on a sack. Campbell was down for about 5 minutes before leaving in the passenger seat of a cart with what the team described as a stinger. There was no word on other information available during the game.

But Gradkowski once again proved more than capable as a backup. After breathing life into Oakland's offense last year when he took over the reins from JaMarcus Russell, Gradkowski was once again relegated to backup status after the Raiders acquired Campbell in the offseason.

Gradkowski did not play in the first two exhibition games because of a groin injury and was in danger of falling behind Kyle Boller on the depth chart. But he completed 14 of 22 passes and led Oakland to scores on his first three drives. He threw touchdown passes to Louis Murphy and Zach Miller and set up a 57-yard field goal by Sebastian Janikowski.

That wasn't enough to win as the Niners put together a 16-play, 80-yard drive to win it. After a slow start, Carr did just enough to win it on that drive. The biggest play might have been Carr's 5-yard run on third-and-3. Carr leaped in the air and was spun around like a helicopter after being hit by a defender a week after Nate Davis went down shy of the marker on a similar play.

Anthony Dixon pushed it up the middle on third-and-goal from the 1 to give the Niners the lead with 1:44 remaining. Carr's pass to Nate Byham for the two-point conversion made it 28-24.

Todd Watkins dropped a deep pass inside the 5 on fourth down to end Oakland's hopes at a comeback.

Frank Gore ran for 58 yards on two carries in his first action of the preseason for the Niners, Alex Smith threw a touchdown pass and rookie Phillip Adams scored on an 83-yard punt return as San Francisco remained undefeated in the preseason.

Campbell got off to another strong start, completing four passes for 67 yards on the 81-yard touchdown drive. Darrius Heyward-Bey had two of his three catches on the drive, fullback Marcel Reece had a 34-yard reception and Michael Bush scored on a 1-yard run.

Oakland didn't get another first down until the final minute of the first half, and even that play lost 2 yards when Mario Henderson was called for a personal foul.

Two plays later, Gradkowski hit Murphy on a seam route behind safety Reggie Smith for a 74-yard touchdown that cut San Francisco's lead to 17-14 at the half.

In between the two touchdowns, the Raiders had four straight three-and-outs as the offense struggled to get into any kind of rhythm against Patrick Willis and the Niners defense.

Willis had two tackles behind the line of scrimmage against Darren McFadden and an 11-yard sack against Campbell. It was the other sack of the first half that knocked Campbell out. Travis LaBoy beat left tackle Marion Henderson and drove Campbell to the turf.

The Niners offense also started well, getting a 49-yard run from Gore on his first carry of the preseason. Gore ran over Michael Huff and Stanford Routt on the play, showing he needs little work in exhibition games. Gore had one more carry and dropped a pitch before leaving for the night.

"It feels great, man, especially going through training camp all month and I didn't get to go against another team," Gore said. "I was like a little kid out there. I was happy."

San Francisco's first touchdown came on Adams' return. The seventh-round draft pick just started fielding punts in practice this week but could have done enough to make the team with his three returns for 116 yards.

Then late in the half, Brian Westbrook had a 17-yard run on his second carry of the preseason to help set up Smith's 16-yard touchdown pass to Josh Morgan. Smith was 9 for 15 for 113 yards.

Notes: Niners LT Joe Staley left the game with a strained knee. ... The 49ers played without WR Michael Crabtree (neck), while CB Chris Johnson (hamstring) and DT Richard Seymour (triceps) missed the game for Oakland.