Toronto, Canada – The 49ers forced seven turnovers and quarterback Alex Smith produced two touchdown passes for San Francisco, who kept alive their own slim playoff chances.
"I can't express how proud I am of our team," 49ers coach Mike Singletary said. "Most teams would have quit (and said) we're not going to make the playoffs but we came out and played well."
Smith, who has excelled since being made starting quarterback in late October, connected with Vernon Davis from five yards out and Michael Crabtree for 35 yards as the 49ers raced to a 17-0 halftime lead.
Arizona clawed back to 17-9 with 14:03 left on a one-yard scoring run from Beanie Wells, but he fumbled a few minutes later to give up possession at the Cardinals' 16-yard line.
Running back Frank Gore capitalized with a two-yard touchdown run for the 49ers and finished with 167 rushing yards.
The Cardinals (8-5) finished with five fumbles and two interceptions by Kurt Warner for a turnover total that matched the NFL season's highest. Warner had made 130 passes without an interception and went without a touchdown pass for the first time this season.
"It was one of those things where the ball didn't bounce in our direction," Warner said.
"There were some instances where guys were trying to gain extra yards and at times they knew what we were doing and made good plays. It was a mistake-filled game we have to correct and move forward."
NFC champions Arizona can still clinch the division by winning two of their final three games. They entered the night having humbled the Minnesota Vikings 30-17 last week.
But after five first-half turnovers, Arizona's misery was further compounded when a third quarter injury forced top receiver Larry Fitzgerald from the field, although he later returned.
Ahmad Brooks led the San Francisco defense with three sacks while safety Dashon Goldson forced two fumbles and had an interception.
The 49ers had lost six of eight games entering the night, but salvaged some optimism with their latest win.
"We still feel we're a championship team," Goldson said. "Our mindset and heart is still in this season."
(Writing by Jahmal Corner in Los Angeles; Editing by Greg Stutchbury/Ian Ransom)