SAN FRANCISCO (AP) -- Alex Smith is realistic. He expected to get booed again. A win feels great, yet it's still only one.
Somebody had to come through all the sloppiness - and Smith raised his game at last.
When the home crowd began jeering Smith for a second straight week and begging for backup David Carr , it looked to be another long day for San Francisco's embattled quarterback.
"You've got to start with one. You've got to start somewhere," Smith said. "You try to fix the negatives and build on the positives from the last five weeks."
Crabtree made a go-ahead 32-yard TD reception on the last play of the third quarter and Smith hit Davis on a 17-yard score with 7:14 remaining. Frank Gore ran for 149 yards, including a 64-yard scramble that set up Davis' third touchdown of the season.
"I feel like I just took a whole house off my back that was weighing us down," Davis said.
Smith overcame a slow start to go 16 of 33 for 196 yards in his first turnover-free game of 2010, though San Francisco committed 11 penalties for 143 yards. The Niners, whose 1-5 start is the franchise's worst since Bill Walsh's first team lost its initial seven games in 1979, denied Oakland its first back-to-back victories since 2008.
Sebastian Janikowski kicked field goals of 27, 24 and 40 yards for the Raiders (2-4). Oakland had eight penalties for 60 yards in a game that was played through a steady drizzle into the second half.
Jason Campbell , like Smith a first-round draft pick in 2005, completed 8 of 21 passes for 83 yards and was sacked twice playing in place of the injured Bruce Gradkowski . The Raiders struggled to convert on offense a week after they beat the Chargers to end a 13-game losing streak to San Diego.
Oakland drove inside the Niners 10 on its first two series but settled for field goals. Janikowski kicked a 40-yarder with 8:21 left, set up by two long catches by Zach Miller .
"We started off strong but we didn't get those touchdowns and it was kind of like the air went out," Campbell said. "It was a frustrating day. We lost a lot of opportunities. We will do better next time. I don't see this happening to us again."
This marked the first regular-season meeting between the rivals since 2006 - and it was played exactly 21 years after the Bay Area earthquake hit when these teams played at Candlestick Park in 1989.
This one wasn't anything special - a matchup of teams that each have gone seven straight seasons without a winning record. Oakland has failed in seven tries the past two years when trying for consecutive wins.
"It's not like we get overconfident," cornerback Nnamdi Asomugha said. "It's just something we have to do. We just have to win that second game."
After the first drive of the second half, San Francisco had 123 yards in penalties and 137 yards of offense.
Crabtree said during the week he wanted to have a big game against the team that picked Darrius Heyward-Bey instead of him at No. 7 in last year's draft. Crabtree, picked three spots later at 10th, had four catches for 57 yards to Heyward-Bey's three for 19.
Smith faced boobirds for the second straight Sunday at home. This time, they started at the 10:18 mark of the second quarter. It's been a rough go for Smith, who committed seven turnovers in the 49ers' three narrow losses - by eight combined points against New Orleans, Atlanta and Philadelphia.
"We've had three really close games this year. A lot of these hurt. Today to go out and play how we did, staring 0-5 in the face, we stayed patient," Smith said.
Coach Mike Singletary nearly benched him last week after a heated conversation on the sideline but Smith talked him out of it. The QB then led two late touchdown drives before throwing a pick on San Francisco's final possession in a 27-24 loss to the Philadelphia Eagles .
Linebacker Manny Lawson made an athletic, diving catch in front of Miller to get the Niners the ball back early in the second, but they couldn't capitalize.
San Francisco avoided becoming the NFL's only 0-6 team. Buffalo and Carolina are 0-5 but were idle Sunday.
"It was desperation. We needed this," said linebacker Takeo Spikes , who had a late interception. "But we aren't satisfied. This is a stepping stone, and there's no turning back from here."
The 49ers were the popular pick to win the NFC West before the season began. This franchise thought for sure it would end a seven-year playoff drought - though that will be a tough task. The three other divisional teams all have three victories. San Francisco goes to Carolina next week before flying to London to face the Denver Broncos on Oct. 31.
Niners team president Jed York said after the last-second loss to the Eagles that his club would still win the West and make the playoffs.
"It gives them energy and motivation," Singletary said. "Just the perseverance, our guys being able to hang together and stay together in spite of all the other stuff that's going on, I think it's important."
Notes: Before Crabtree's TD, the 49ers were the only team without a touchdown longer than 20 yards. ... Gore moved into third place on the franchise's all-time rushing list with 6,032 yards. He trails Joe Perry and Roger Craig. ... The teams combined for 243 yards of offense in the first half.