Smith rallied the Niners for three scores but Eugene Wilson's interception on fourth down in the final seconds halted a last-gasp drive. Steve Slaton scored two touchdowns and the Houston Texans held on for a 24-21 win over San Francisco.
The Niners benched Shaun Hill after a terrible first half, and Smith threw three touchdowns to Vernon Davis to close the gap. Michael Crabtree started in his NFL debut and had five receptions for 56 yards. The Texans won consecutive games for the first time this season.
San Francisco has dropped two straight games and now stand at 3-3 heading next Sunday to Indianapolis to face the undefeated Colts.
Davis' third touchdown came on a 23-yard reception that got San Francisco within 24-21 with 3:49 remaining. Houston's only second-half points came on a 50-yard field goal by Kris Brown with about 7½ minutes left.
Crabtree's first game after ending a 71-day contract holdout Oct. 7 was overshadowed by the quarterback shakeup. In his first game since 2007, Smith sparked San Francisco's offense in the second half and was 15 of 22 for 206 yards. The former No. 1 overall draft pick made only one major blunder -- the desperation throw that Wilson picked off.
His first touchdown came on a 29-yard pass to Davis that made it 21-7, finishing a drive that included a 17-yard reception by Crabtree.
Smith found Davis again on a 14-yard touchdown pass to cut the lead to 21-14 with about 13 minutes remaining. That score came 10 plays after Dashon Goldson forced and recovered a fumble by Slaton late in the third quarter. It was the fourth fumble he's lost this season after losing two as a rookie last year. Davis finished with seven receptions for 93 yards.