Gradkowski threw for 202 yards and two touchdowns after Jason Campbell left with an injury, and Carr led a late touchdown drive that gave the Niners a 28-24 victory Saturday night.
San Francisco's first defense allowed three touchdowns and the team committed 10 penalties but the Niners still managed to squeak out their third straight preseason win.
"We did not play very smart, and a little bit sloppy," 49ers coach Mike Singletary said. "Winning the game was nice, but it also was a reminder to our guys of all the work we still have to do."
The Raiders also have work to do. Coach Tom Cable was upset about poor tackling on defense and special teams and an offense that stalled for a long stretch in the first half.
"There's too many ups and downs in this football game for us to be who we need to be to succeed," Cable said. "A lot to learn from it, and that's a good thing. I'm glad it happened now as opposed to a few weeks from now."
It's also fortunate that Campbell has two weeks before the season opener to recover from the stinger that knocked him out in the second quarter.
He was down for about five minutes before leaving in the passenger seat of a cart. He watched the second half from the sideline.
"It felt a lot worse at the time that it happened, but ... they don't think it's going to be really, really serious," Campbell said. "But at the same time it's something we've got to take care of before the season starts."
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.
"It felt like just where I left off," Gradkowski said. "It was exciting. It feels so great to be out there and playing and competing. We have a really good football team and we're excited about it."
The Niners put together a 16-play, 80-yard drive to win it. 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.
"I'm trying to inspire my team," Carr said. "That's all I'm trying to do. They did a great job the first 12 plays of that drive. I'm just trying to finish it off. It was a spur of the moment play."
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 to Josh Morgan 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.
Gradkowski then 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. Patrick Willis had two tackles behind the line of scrimmage against Darren McFadden and an 11-yard sack against Campbell. Travis LaBoy later beat left tackle Mario Henderson for a sack and knocked Campbell out.
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.
"After a month of training camp, finally getting to play in a game, I was like a little kid out there," Gore said. "When my number got called, I took advantage."
- Bush also left the game with a broken left thumb and does not know how serious it is. DT Desmond Bryant had an elbow injury.
- Niners LT Joe Staley (sprained knee) and Westbrook (hamstring) are day to day.
- Niners WR WR Michael Crabtree did not play because of a stiff neck.