Kurt Warner's ageless arm and an improbable goal-line stand at the finish saved the Arizona Cardinals from an ugly loss on a national stage.
The Cardinals stopped Michael Robinson up the middle from the 2-yard line as the game ended Monday night to preserve a 29-24 victory over the San Francisco 49ers.
Warner finished 32-of-42 for 328 yards and three touchdowns without an interception in Arizona's sixth consecutive home victory, fourth this season.
The NFC West-leading Cardinals (6-3) never led until Karlos Dansby's 34-yard interception return set up Warner's 5-yard TD pass to Anquan Boldin with 4:16 to play.
San Francisco (2-7) had two chances after that.
The first ended on Adrian Wilson's diving interception of Shaun Hill's pass. The second was much more nerve-racking for the home team and exasperating for the 49ers, who lost their sixth in a row.
Hill's 14-yard pass to Jason Hill moved it to the Arizona 1. With the last few seconds ticking off, 49ers running back Frank Gore was pushed by a defensive player as he ran around left end, then stumbled to the ground just outside the 2.
After officials reviewed the play to make sure Gore was down by contact, the 49ers handed off to the fullback Robinson, who was stuffed nowhere near the goal line.
Arizona coach Ken Whisenhunt stressed the positives, including the goal-line stand.
"We found a way to win a tough game, which is something you have to do," he said.
The Cardinals won on Monday night for the first time since they moved to the desert 20 years ago and opened a four-game lead in the NFC West. The other three teams in the division -- San Francisco, Seattle and St. Louis -- are all 2-7.
Allen Rossum returned the opening kickoff 104 yards for a touchdown and the 49ers never trailed until Arizona's late score.
"It would have been nice to have a blowout but hey, those games are sweet when you win," Warner said. "Man, it's fun. It's fun to pull these out. It would have been a heartbreaker to have lost it."
Shaun Hill, replacing the benched J.T. O'Sullivan for his third career start in seven NFL seasons, threw for two touchdowns in the first half but lost a fumble and threw two interceptions in the second. He finished 19-of-40 for 217 yards.
Rossum, who left the Seattle game two weeks ago with a hamstring injury, showed no ill effects on the opening kickoff. He caught the ball four yards deep in the end zone, then ran upfield and darted to his left, going untouched yards for a touchdown.
It was his fifth career kickoff return for a score and was just one yard short of the team record.
Tight end Vernon Davis, sent to the locker room by interim coach Mike Singletary's two weeks ago during a loss to Seattle, caught an 18-yard pass over the back of Wilson for a touchdown with 29 seconds left in the half to give San Francisco a 21-13 lead.
The 49ers had gone ahead 14-3 on Josh Morgan's juggling catch of Hill's 31-yard touchdown pass with 14:13 left in the half. That's when Arizona's vaunted offense finally got in gear. Warner's 46-yard pass -- at least 50 yards in the air -- to Steve Breaston set up a 13-yard TD pass to Boldin that cut the lead to 14-10. Neil Rackers' second field goal of the half, from 33 yards, made it 14-13.
But the 49ers went 77 yards in 14 plays for their final first-half touchdown. The crucial play came on third-and-11 from the San Francisco 22 when Shaun Hill kept the ball, had his helmet ripped off but still got the final two yards of a 12-yard gain for the first down.