Overall, he completed 20-of-31 passes, with a 2-yard, third-quarter touchdown pass to Vernon Davis.
Frank Gore scored once on 28 carries for 71 yards and added four catches for 81 yards.
Ricky Schmitt kicked two first-half field goals and Michael Crabtree caught four passes for 68 yards for the 49ers (7-8), who have won two of three.
Detroit's only points came on first- and fourth-quarter field goals by Jason Hanson.
Drew Stanton, making his first career start, completed 11-of-21 passes for 130 yards, three interceptions and a lost fumble.
Wide receiver Calvin Johnson caught seven passes for 96 yards, gained 32 yards on two carries, but lost two fumbles for the Lions (2-13), who have dropped five in a row.
It was their 20th straight road loss.
Copyright 2009 by United Press International.