SAN FRANCISCO -- The San Francisco 49ers sit alone atop the NFC West for now -- hardly the kind of firm hold on the division they owned last October.

Alex Smith threw a 12-yard touchdown pass to Delanie Walker late in the third quarter, and San Francisco held off the Seattle Seahawks 13-6 on Thursday night as the 49ers won their long-awaited division opener.

Frank Gore ran for 131 yards, and the 49ers (5-2) took over sole possession of first place in the NFC West by making just enough plays to win this defense-first game featuring two teams allowing fewer than 16 points per game.

"That was the most physical 30 minutes of football in the second half that I have ever seen our football team play," 49ers coach Jim Harbaugh said. "It's a sweet win. It was a real football fight, and our guys won it."

Walker's score was San Francisco's first touchdown in seven quarters after an embarrassing 26-3 loss to the New York Giants on Sunday in a lopsided rematch of the NFC championship game. The tight end broke his jaw in two places at Seattle last Dec. 24 and sat out until the title game.

Smith went 14-of-23 for 140 yards in another subpar performance. The defense hung tough down the stretch.

It's now Harbaugh 3, Pete Carroll 0 since these two coaching rivals started facing off in the NFL last year after all those memorable moments in the college game.

Harbaugh's teams sure have shown they are quick to forget their losses. The 49ers improved to 5-0 after regular-season defeats since reigning NFL coach of the year Harbaugh took over before last season.

Pulling off this one could give the 49ers some momentum, too. It was the first of two straight prime-time games for San Francisco, which doesn't play again until Oct. 29 at Arizona.

The defensive fight left the animated coaches shaking their heads and hollering on opposite sidelines all game, offering plenty of entertainment for the sellout crowd of 69,732 at balmy Candlestick Park.

"We found ourselves in a real slugfest here today," Carroll said. "I'm not surprised it could have gone that way with two good defenses and two teams committed to running the ball."

These teams met in Weeks 1 and 16 last season, with the 49ers beating Seattle 33-17 at home for Harbaugh's first victory as an NFL coach.

This one was close until the end.

"We had a long drive in the third quarter. We just kind of felt them start to give up a little bit, and they knew we were just going to keep running the ball on them," 49ers right guard Alex Boone said. "It was more of, 'Let's get back to our roots and do what we're good at' -- that's being physical, pounding the ball. Frank's a great runner."

Smith gave the ball back with an interception of his own early in the fourth quarter. His fifth interception of the season matched his total from all of 2011.

Harbaugh went to backup Colin Kaepernick for one keeper play that lost a yard, then Smith returned for third-and-goal on the 7. He scrambled to his left looking for an open receiver, and Brandon Browner jumped in front of a pass intended for Randy Moss.

That gave Seattle the ball back with 11:58 remaining. Yet again, the Seahawks couldn't capitalize on a night of missed opportunities and dropped balls.

Gore had his third 100-yard game of the season, not to be outdone by Lynch on the other side.

"I just got in that rhythm, and once I get in that rhythm, I feel I can't be stopped," Gore said.

Lynch carried 19 times and bounced back from a 41-yard outing in Sunday's comeback 24-23 home win against the Patriots. The 49ers and their top-ranked defense hadn't allowed a 100-yard rusher in 22 consecutive home games before New York's Ahmad Bradshaw ran for 116 yards and a touchdown Sunday -- and now the Niners made it twice in five days.

Not that they should have been too surprised. This is Lynch, after all.

The last time they faced off, on Dec. 24, Lynch ran for 107 yards as San Francisco's defense had its streak of not allowing a 100-yard rusher end at 36 games. And his 4-yard touchdown run in the fourth quarter also was the first TD rushing allowed by San Francisco all season.

Wilson, who said leading up to the game that he couldn't wait for his introduction to this heated rivalry, went 9-of-23 for 122 yards, an interception and two sacks. Aldon Smith sacked him with 1:25 left, then Paul McQuistan was called for a chop block on Smith in the end zone with 43 seconds left. It would have been an automatic safety, but the 49ers declined the penalty. The play was reviewed, and Seattle was short of the first down.

Wilson struggled four days after he threw two late touchdown passes as the Seahawks rallied for 14 points over the final 7:31 to stun New England on Sunday.

"The way we lost was frustrating. We could have done some things better," Wilson said. "I could have done some things better."

San Francisco was in control of the division at this stage last season -- sitting at 5-1 -- but needed a big second half Thursday after a quick week of preparation to stay in first place.

Steven Hauschka kicked a 52-yard field goal as Seattle scored first for the seventh time in as many games this year. He added a 35-yarder early in the second quarter but missed wide left on a 51-yard try later in the quarter.

David Akers, who had eight of his NFL-record 44 field goals in the two games against the Seahawks last season, booted a 38-yarder late in the first quarter to make it 3-3.