SAN FRANCISCO -- One season later, there was far less drama but the same result when the San Francisco 49ers and Detroit Lions met in a rematch Sunday night at Candlestick Park.
Quarterback Alex Smith threw for 226 yards and two touchdowns, both to tight end Vernon Davis, leading the 49ers to a 27-19 victory.
When the 49ers faced Detroit last year in Week 6, they had to come from behind for a 25-19 win in a game that's remembered most for an altercation between 49ers coach Jim Harbaugh and Lions coach Jim Schwartz after the final gun. Harbaugh gave Schwartz a hard handshake and a slap on the back that day, and Schwartz took exception.
This time, the two coaches met on the field before the game for a friendly handshake and a brief chat. There were no postgame fireworks when they shook hands again.
"I thought it was good," Harbaugh said. "It's just about this matchup, two good teams. That's the story, two good teams going at it early in the season."
Smith's 23-yard touchdown pass to Davis with 3:04 to play put the 49ers ahead 27-12. Detroit cut the lead to 27-19 on Matthew Stafford's 9-yard touchdown pass to tight end Brandon Pettigrew with 1:29 remaining.
San Francisco wide receiver Kyle Williams then recovered the Lions' onside kick.
The 49ers beat Detroit for the ninth straight time and the 14th time in the past 15 meetings, but they needed one of Smith's best games and a stellar effort from their defense to do it.
Smith completed 20 of 31 passes for 226 yards and two TDs, outdueling Stafford. He had a passer rating of 107.7 to Stafford's 78.9.
"I don't think on offense we've hit our stride yet," Stafford said. "We didn't take advantage of our opportunities in the red zone."
Harbaugh said Smith had one of the best performances of his career, and pointed to his toughness after taking a forearm to the bridge of his nose, bringing blood, at the end of a slide during a fourth-quarter drive.
"He's as tough as a two-dollar steak," Harbaugh said. "I grew up eating a lot of them. I know what I'm talking about."
Running back Frank Gore rushed for 89 yards and one touchdown on 17 carries for the 49ers. Davis caught five passes for 73 yards, and wide receiver Michael Crabtree had six receptions for 67 yards, including three crucial third-down catches, good for first downs, on the 49ers' final TD drive.
"Whatever Alex threw, I was trying to catch it," Crabtree said. "I felt bad. On one third-down pass, I dropped it. I tried to redeem myself."
The 49ers' defense contained Stafford, wide receiver Calvin Johnson and Detroit's explosive passing attack for most of the night.
Stafford, who threw for 5,038 yards and 41 touchdowns last season, had 89 passing yards and no TDs through the first three quarters and finished with 230 yards and one scoring pass. Johnson caught 96 passes for 1,681 yards and 16 TDs last year. He had six catches for 46 yards and no scores entering the fourth. He finished with eight catches for 94 yards but no scores.
After building a 14-6 halftime lead, the 49ers took the opening kick in the second half and marched 62 yards for a 36-yard David Akers field goal, making it 17-6.
The Lions spent much of the first half trying to establish a running game against one of the NFL's top run defenses, and they kept trying in the third quarter. They marched methodically to the 49ers' 22 but stalled. Jason Hanson's 40-yard field goal cut the 49ers' lead to 17-9 with 3:40 left in the third.
Stafford said the 49ers were dropping defenders deep to defend the pass and giving them opportunities to run and stay balanced on offense. The Lions gained 82 yards on 26 carries, with Kevin Smith leading the way with 53 yards on 16 attempts.
"It was the game plan in the beginning of the week," Lions running back Joique Bell said. "Coach (Schwartz) wanted to be able to run the ball. I think we did a pretty good job as far as running. That was part of the game plan to be able to test them."
The 49ers got a 48-yard field goal from Akers with 14:42 to play, extending their lead to 20-9. Hanson's 48-yarder made it 20-12 with 9:16 left to play.
The 49ers forced a three-and-out on Detroit's game-opening possession, then needed just four plays and 1:12 to drive 67 yards for a touchdown on Smith's 21-yard strike to tight end Davis.
After Smith threw an incompletion on first down, Mario Manningham gained 29 yards on an end-around, and Smith hit receiver Crabtree for 17 yards to the Lions' 21. On the next play, Davis ran past Lions safety John Wendling, and Smith hit him in stride in the back left corner of the end zone, giving the 49ers a 7-0 lead with 12:25 left in the first quarter.
"I think all around as a defense, we just need to pick it up," Lions defensive end Cliff Avril said. "We need to make plays when we are supposed to make plays and keep getting the offense the ball."
Detroit countered with Jason Hanson's 38-yard field goal, cutting the 49ers' lead to 7-3. The Lions got the ball back when linebacker Tahir Whitehead caused 49ers kick returner Kendall Hunter to fumble, and Kassim Osgood recovered at San Francisco's 25. The 49ers had gone 26 straight quarters without a turnover before Hunter's fumble.
The Lions failed to get a first down and settled for Hanson's 41-yard field goal -- it bounced in off the right upright -- slicing the 49ers' lead to 7-6 with 6:43 left in the first half.
Late in the first quarter, 49ers safety Dashon Goldson made a diving interception of a Stafford overthrow and returned it 20 yards to the Detroit 23. It appeared the 49ers would have to settle for Akers' 35-yard field goal, but Lions cornerback Drayton Florence was flagged for running into the kicker. That gave the 49ers a first down at the 12. Two plays later, Lions cornerback Jacob Lacey was penalized for pass interference in the zone while covering Randy Moss.
Gore, who rushed for 61 yards on 10 carries in the first half, rammed into the end zone from a yard out, giving San Francisco a 14-6 lead with 14:57 left in the half.
Late in the half, the Lions drove 65 yards but came away empty when Hanson's 40-yard field goal hit the right upright and bounced backward.
NOTES: The Lions came into the game short-handed in the secondary. Three of their four starters were out with injuries: cornerbacks Chris Houston (ankle) and Bill Bentley (concussion) and free safety Louis Delmas (knee). Florence and Lacey started at cornerback, while Wendling started at free safety. Florence signed with the Lions two weeks ago after being waived by Denver. Strong safety Erik Coleman was the only regular in the secondary who started. ... Rookie wide receiver A.J. Jenkins, the 49ers' first-round draft pick, was inactive. So was running back LaMichael James, San Francisco's second-rounder. ... Ted Ginn Jr., the 49ers' top return man, was out with an ankle injury.