GLENDALE, Ariz. -- The Arizona Cardinals had a chance to sneak into the playoffs by finishing 11-5. But that alone would not have been enough to get them to the postseason.
In addition to having to beat the visiting San Francisco 49ers, they needed the New Orleans Saints to lose at home to the Tampa Bay Buccaneers.
Neither scenario happened on Sunday.
The 49ers got a 40-yard field goal from Phil Dawson as time expired to beat the Cardinals 23-20 at University of Phoenix Stadium.
"I hit it pretty good," Dawson said. "I didn't wait around to see how much it cleared by. Coach (Brad) Seely (special teams coordinator) asked me leading up to that before third down how I felt and I said, 'Well, I'll at least get it there,' and fortunately, that proved to be true."
Linebacker NaVorro Bowman played a major role in the 49ers' victory, getting an interception and recording a forced fumble and a fumble recovery as well as a sack.
The Saints, meanwhile, rolled over the Tampa Bay Buccaneers 42-17 behind four touchdown passes and a touchdown run by quarterback Drew Brees.
The 49ers earned the NFC's No. 5 seed and will travel to Green Bay to take on the Packers, the NFC No. 4 seed, in their first-round playoff game next Sunday.
Quarterback Carson Palmer was 28-of-49 passing for 407 yards and two touchdowns for the Cardinals and became the first quarterback in NFL history to throw for 4,000 or more yards in a season for three different teams.
He did it twice while with the Bengals and also last season for the Raiders, but it was not enough to get his team into the postseason.
"Personal goals are always nice," Palmer said, "but that wasn't one of my personal goals. I wasn't worried about it or thinking about it. I was thinking about wins and losses. ... It just took us awhile to get going today. We didn't make enough plays when it came to it."
Wide receiver Anquan Boldin, in his first game back in Arizona since leaving the Cardinals following the 2009 season, caught nine passes for 145 yards and a touchdown for the 49ers, who are headed to the playoffs for a third consecutive season under head coach Jim Harbaugh.
"It was a huge game for Anquan," Harbaugh said. "This No. 81 now is terrific. What a football player. You can sum him up right there. Football player. That pretty much summarizes everything good that you can say about a football player. He's all of it. Leadership, big-play ability, competitiveness."
Quarterback Colin Kaepernick was 21-of-34 for 306 yards and two touchdowns for San Francisco (12-4), which won its sixth straight game to end the regular season.
But it wasn't easy.
The Cardinals (10-6) fought back from a 17-0 first-quarter deficit, getting a 1-yard touchdown pass from Palmer to tight end Jake Ballard in the second quarter and a 49-yard field goal from Jay Feely early in the fourth quarter to stay in the game.
If it had not been for the Cardinals' sixth-ranked defense, the deficit could have been a lot worse. San Francisco quickly marched down the field on its opening possession and had three chances to get a touchdown from inside the 10-yard line.
The 49ers, though, were forced to settle for a 27-yard field goal from Dawson.
Bowman helped them get more, though, when he stepped in front of a Palmer pass intended for Michael Floyd and picked it off. Floyd was covered by three 49ers defenders.
Five plays later, Kaepernick found Boldin for a 4-yard touchdown pass in the right corner of the end zone for a 10-0 lead with 8:33 left in the first.
A 63-yard catch and run by Boldin on San Francisco's next possession helped set up another Kaepernick touchdown pass -- this one to tight end Vernon Davis for 3 yards to make it 17-0.
Earlier, Feely missed from 37 yards when his attempt was wide right.
A solid defensive effort by the Cardinals helped prevent yet another San Francisco score, however, and a 49-yard pass play from Palmer to Larry Fitzgerald set up a 1-yard scoring pass from Palmer to Ballard.
Dawson missed a 24-yard field goal at the end of the first half, hooking it left.
At the end of the third quarter, Arizona converted a fourth-and-1 at the 49ers' 35, keeping a drive alive long enough for Feely to connect from 49 yards early in the fourth and pull the Cardinals to within 17-10.
The Cardinals had another chance to get even closer, but Feely pushed a 43-yard field goal attempt wide right again midway through the final quarter.
But the Cardinals were not done. After forcing the 49ers to punt after four plays from scrimmage, Palmer led them downfield just like he did during last week's 17-10 stunner in Seattle and completed a long touchdown pass.
This time, it was a 35-yarder to Andre Roberts, who cradled the ball awkwardly but held onto it as his body hit the ground and rolled out of bounds in the left corner of the end zone.
With 3:20 left in regulation, it suddenly was tied at 17-17.
However, it would not matter for the Cardinals because at that time, the Saints were rolling over the Buccaneers midway through the fourth quarter.
Dawson kicked a 56-yard field goal with 1:50 left to give the 49ers a 20-17 lead, but Palmer led the Cardinals down the field and gave Feely a shot at some redemption. Feely made a 43-yarder with 34 seconds left to tie it, but that's the best Arizona could do.
Kaepernick hit Quinton Patton for a huge 29-yard gain on the 49ers' ensuing possession, and Dawson won it with his 40-yard field goal.
"It's been a good year," said Cardinals first-year coach Bruce Arians, whose team mad a five-win improvement from last year. "I really hate to see this football team's season end because it's been so much fun working with them and because no team stays the same in the NFL anymore. There's so much change and turnover. We will do everything we can to keep this core group of this football team together because there are a lot of winners in this locker room and they learned how to win this year.
"I'm very, very proud of them."
NOTES: Cardinals nose tackle Alameda Ta'amu suffered a right knee injury in the second quarter and did not return. ... San Francisco RB Frank Gore entered the game needing 47 rushing yards to hit 10,000 in his career. He finished with 14 yards on 13 carries, leaving him 33 yards shy of the milestone. ... Arizona's defense allowed just five rushing touchdowns on the season, setting a new franchise record for a 16-game season. The previous low was seven rushing TDs in 1994.