Updated

Vernon Davis' 23-yard touchdown reception late in the fourth quarter helped the San Francisco 49ers seal a 27-19 victory over the Detroit Lions at Candlestick Park on Sunday.

Davis finished with 73 yards and two scores on five catches for the 49ers, who were coming off an impressive 30-22 decision over the Green Bay Packers last week.

Alex Smith completed 20-of-31 passes for 226 yards and the two scores to Davis, while Frank Gore carried the ball 17 times for 89 yards and a touchdown for San Francisco (2-0).

Matthew Stafford went 19-for-32 through the air for 230 yards, a touchdown and an interception for Detroit (1-1), which never led in the game and could not recreate its dramatic, 27-23, come-from-behind victory over the St. Louis Rams in Week 1.

Calvin Johnson led all receivers with 94 yards on eight catches, and Kevin Smith had 53 yards on 16 carries in defeat.

"I don't think, as an offense, we have hit our stride yet. We moved the ball really well at times today against a really good defense and then didn't take advantage of our opportunities in the red zone like we need to against a team like that," Stafford said. "We didn't play our best game really in any of the phases today."

It was the first meeting between the teams since Lions coach Jim Schwartz confronted 49ers coach Jim Harbaugh following San Francisco's 25-19 win in Week 6 of last season when Schwartz took exception to Harbaugh's hard handshake at the end of the game.

Schwartz nearly followed Harbaugh into his team's locker room and had to be restrained by members of his team, but there was no such incident at the end of this contest as the coaches cordially shook hands and walked away.

After the Lions were held to a three-and-out on the opening possession of the game, Mario Manningham reeled off a 29-yard run on an end around before Smith capped a quick 4-play, 67-yard scoring drive with a 21-yard strike to Davis down the left sideline.

A 33-yard pass interference penalty on Chris Culliver during Detroit's next touch moved the ball down the San Francisco 26-yard line, but the Lions managed just six more yards of offense and had to settle for Jason Hanson's 38-yard field goal.

Kendall Hunter then lost a fumble on the ensuing kickoff and Detroit recovered the ball at the 49ers' 25, resulting in Hanson's 41-yard kick that deflected off the right upright to make it a 7-6 game with just under seven minutes left in the first quarter.

San Francisco was able to regain some cushion following a punt, though, as Dashon Goldson made a diving interception of an errant Stafford pass and returned it 20 yards down to the Detroit 23-yard line.

A running into the kicker penalty during a David Akers 35-yard field goal gave the 49ers a new set of downs, and after a pass interference call on Detroit's Jacob Lacey gave San Francisco the ball at the 1-yard line, Gore rumbled across the goal line on the first play of the second quarter.

The Lions later had a chance to cut into its deficit by putting together a nearly six-minute drive that moved deep into San Francisco territory, but Hanson's 40-yard field-goal attempt connected with the right upright to keep it a 14-6 game at the half.

Akers had field goals of 36 and 48 yards while Hanson was true on kicks of 40 and 48 yards over the first four possessions of the second half to put San Francisco on top, 20-12, with 9:16 left in the game.

The 49ers were then able to snap the streak of field goals with a 13-play, 79- yard march that included three separate third-down conversions before Smith found Davis for a short pass on the ride side.

Davis raced down the right sideline, but then cut to the left, avoided three Detroit defenders and slipped across the goal line for a 23-yard score with about three minutes remaining.

Stafford answered with a nine-yard touchdown strike to Brandon Pettigrew with 1:39 left, but the Lions could not recover an onside-kick attempt.

"We knew it would be a tough, close, aggressive, bell-ringing game and then it was," Harbaugh said. "We expected a physical game, anticipated that and got that. They area physical team. That's good. That keeps us playing hard and fast and tough. Our guys are accustomed to that and aren't going to shy away from that type of ballgame."

Game Notes

San Francisco has won the last nine meetings between the teams and leads the all-time series, 36-26-1 ... Stafford failed to surpass 350 yards passing for the first time in five games. His streak of four games with over 350 yards through the air tied the Saints' Drew Brees for the longest in NFL history after Brees also failed to surpass 350 yards on Sunday ... Smith improved to 4-0 in his career against the Lions ... Gore also caught two passes for 16 yards.