San Francisco's NaVorro Bowman had an interception, a forced fumble, a fumble recovery and a sack in the 49ers' ninth victory in the last 10 meetings with Arizona.
Boldin did most of his damage in the first quarter, with six catches for 106 yards, including a 4-yarder for a touchdown and a 63-yard play to set up another TD.
But that was it for the San Francisco offense until Dawson's late two kicks.
Bowman's sack had put Arizona in third and 13 when Palmer lofted one to the end zone, where Roberts gathered it in just as he was sliding out of bounds on a slippery turf recently re-sodded for Wednesday's Fiesta Bowl.
Kaepernick's 18-yard pass to Boldin helped set up Dawson' 56-yarder, matching his longest, set in 2008.
Palmer, though, connected on passes of 24 yards to Rob Housler and 23 yards to Fitzgerald to give Feely a chance for redemption, and the kick that tied it at 20.
With the game seemingly headed for overtime, James raced from 5 yards deep in the end zone to the 49ers 40, then Kaepernick, in a play that started with just 18 seconds to play, completed a perfect pass to the untested Patton.
"I liked the matchup and there was no safety on that side of the field," Kaepernick said. "I thought I would give him a chance. He has shown that he can go up and make those plays in practice. He came up with it and it was huge for us."
Then, Dawson's final field goal ended it.
Notes: The 49ers beat Green Bay 34-28 in San Francisco in the season opener ... Arizona NT Alameda Ta'amu left in the second quarter with a right knee injury. ... Arizona WR Michael Floyd's string of 25 straight catches that went for first downs ended in the first quarter when he caught a 6-yarder. ... The 49ers finished 5-1 against the NFC West; Arizona was 2-4.