SAN FRANCISCO – Jim Harbaugh's San Francisco 49ers sure have a knack for leaving tough losses behind.
They've never lost two games in a row under the reigning NFL Coach of the Year.
This time, the 49ers had all of four days and no choice but to forget in a hurry; first place in the NFC West was on the line.
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 Thursday night to give the 49ers a victory in their long-awaited division opener.
"Coming off a loss, we wanted to go out there and get that mojo back," linebacker Patrick Willis said. "We never lost it, but at the same time, you never want to lose a game. It's a bad taste in everybody's mouth. We just knew we had to come out and play great football against this team tonight."
It wasn't all that pretty, but that hardly matters to the Niners.
They're alone in first place — for now.
"You lose, you move on and you get ready for your next opponent," defensive tackle Justin Smith said. "It just happened to be Seattle, who's in our division."
Frank Gore ran for 131 yards and the 49ers (5-2) hung tough on defense late in a game featuring two teams allowing fewer than 16 points per game.
Alex Smith went 14 of 23 for 140 yards in a second straight subpar performance.
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.
NFC rushing leader Marshawn Lynch finished with 103 yards for Seattle (4-3).
It's now Harbaugh 3, Pete Carroll 0 since these coaching rivals started facing off in the NFL last year after all those memorable moments in the college game.
"That was the most physical 30 minutes of football in the second half that I have ever seen our football team play," Harbaugh said. "It's a sweet win. It was a real football fight, and our guys won it."
The 49ers improved to 5-0 after regular-season defeats since 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've got to figure something out. We've got to figure out a way to get it done," Seahawks receiver Golden Tate said. "The season's not over. We still have a long way to go, so we can't let this set us back. I think we still have the chance to be a real special team."
After Walker's touchdown, Dashon Goldson intercepted a deep pass by Russell Wilson to thwart Seattle's next drive after NaVorro Bowman clobbered the rookie quarterback as he was trying to throw.
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 leading up to the game said that he couldn't wait for his introduction to this heated rivalry, went 9 of 23 for 122 yards, an interception and two sacks after rallying his team late to stun New England.
"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.
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.
NOTES: 49ers LT Joe Staley returned after sustaining a concussion Sunday. ... Seattle lost LB Malcolm Smith to a concussion on the opening kickoff, then WR Doug Baldwin later injured his ankle and did not return.