(Reuters) - Alex Smith proved once again he can handle the big moment, leading San Francisco to a game-clinching drive that finished off the Detroit Lions 27-19 on Sunday and kept the 49ers' perfect start intact.

Smith was flawless in throwing for 226 yards and two scores, and engineered a 13-play 79-yard march downfield that gave the home team a 15-point lead with just 3:04 remaining.

Detroit (1-1) answered with a late touchdown, but it was too little, too late.

The 49ers never trailed, holding down Matthew Stafford and the Lions' offense while Vernon Davis caught a pair of touchdown passes and Frank Gore scored one on the ground.

San Francisco's winning formula of stingy defense, a strong running game and late Smith heroics nearly took them to the Super Bowl last season, and it has them looking just as dangerous in starting this campaign 2-0.

"We were able to hold on and it was a heck of a team win," 49ers defensive tackle Justin Smith told reporters. "We have a lot of players and a one-game mentality. We just keep chopping wood and we were able to get another one."

Stafford finished with 230 yards passing but his offense was held to four Jason Hanson field goals before their late TD.

The Lions trailed 14-6 at halftime and never got any closer in the second half.

Still, the visitors were in striking distance until Smith paced the offense down the stretch and found Davis for a 23-yard strike. The critical drive also included three third-down conversion passes to receiver Michael Crabtree.

"He was the unsung hero," Smith said of Crabtree. "He didn't get the touchdown but he made it happen. Whenever his number was called, he won."

Detroit coach Jim Schwartz and San Francisco's Jim Harbaugh were quick to shake hands prior to the game after the pair were involved in a heated exchange during their post-game handshake in their previous match.

Harbaugh gave Schwartz an enthusiastic slap on the back after the 49ers' victory last season, which the Detroit coach took exception to and ended up angrily chasing his opponent down the field.