The only thing standing between Smith and perfection was a short pass dropped by Delanie Walker. Smith admitted culpability for throwing that second-quarter pass behind Walker, who later made an acrobatic sideline catch on a tipped pass.

Although Smith’s 94.7 completion rate was the best in history for a minimum of 15 attempts, the NFL record book requires 20 attempts — one more than Smith had.

Coach Jim Harbaugh couldn’t recall seeing a better line than Smith’s, and Harbaugh conjured up a unique way to dismiss previous reports that Smith had lost confidence.

“It’s just a lot of gobble, gobble, turkey from jive turkey gobblers,” Harbaugh said. “That paints a pretty good picture.”

Smith quipped about his confidence: “It was in my closet. I found it.”

The 49ers (6-2) find themselves with a two-game lead in the NFC West heading into next weekend’s bye.

Arizona (4-4), after opening the season with four wins, was looking to stop its skid and also make a statement against the reigning division champs.

“It was a big test for us,” said Cardinals coach Ken Whisenhunt, “and everybody saw how it went.”

Michael Crabtree caught two touchdown passes before Randy Moss scored on a 47-yard catch-and-run. Those points, and the Cardinals’ futility, ensured that the 49ers wouldn’t cave as they did in last December’s visit to Arizona, when they blew a 19-7 lead in an eventual 21-19 defeat.

For the fourth time in five games, the 49ers didn’t allow a touchdown, and it took a gang tackle on Larry Fitzgerald’s fourth-down catch to stop him at the 1-yard line in the final minute.

Linebacker Patrick Willis, safety Dashon Goldson and cornerbacks Chris Culliver and Perrish Cox all combined to tackle Fitzgerald on that 6-yard catch. Watching with admiration from the sideline was Aldon Smith, who had two sacks earlier in the fourth quarter.

“That (tackle) says what we’re all about,” Aldon Smith said. “Even though we knew we had the win, everybody was just making an effort to not let that play get on the scoreboard. That’s amazing.”

Also impressive was the 49ers’ matching a franchise single-game record by allowing only 7 rushing yards.

The 49ers defense made a slew of tackles for loss, and its shutout bid didn’t end until the final minute of the third quarter, when Jay Feely kicked a 28-yard field goal.

That field goal only riled up the 49ers defense more. On the Cardinals’ next series, safety Goldson leveled receiver Early Doucet to break up a pass across the middle, a hit that Harbaugh said would have made Vince Lombardi proud. Ahmad Brooks and Aldon Smith produced back-to-back sacks on the next two snaps.

But nothing could overshadow Alex Smith’s bounce-back night. He passed for a season-low 140 yards last game against the Seattle Seahawks, and he had three passes intercepted in an Oct. 14 loss to the New York Giants.

“Honestly I had no idea, which is a good thing,” Smith said of his completion percentage. “I wasn’t worried about incompletions or anything like that.”

All three of Smith’s touchdown passes came on third-down plays. Smith finished with a 157.1 passer rating (158.3 is perfect). Now in his eighth season, Smith isn’t concerned about winning over his skeptics.

“If you had asked me that a few years ago, maybe. But at this point I don’t really care,” Smith said. “I am only concerned about winning, and the guys in the locker room know what I am about.”

Smith matched his single-game career high when he threw his third touchdown pass, although Moss did most of the work on it as he dashed 47 yards for the third-quarter touchdown and a 24-0 lead.

Crabtree and Moss entered the game with only one touchdown apiece. Moss’ score marked his 155th career touchdown, and 18th in 19 career “Monday Night Football” games.

Crabtree staked the 49ers to a 7-0 lead when he beat Patrick Peterson at the goal line to snag Smith’s 3-yard pass on third-and-goal. Crabtree produced a 9-yard touchdown reception to put the 49ers ahead 17-0 with 1:41 left in the first half.

“Great play by Michael,” Harbaugh said of the first touchdown. “And a great throw by Alex. A really strong-hand catch by Michael, and Alex lasered it in there.”

It was a strong performance by Crabtree, who caught five passes for 72 yards while tangling with Arizona’s star cornerback Peterson. Crabtree said he drew no extra motivation from that matchup, but he did take special pride in becoming a red-zone target on that first touchdown.

“I’ve been working so hard with (Smith) at practice to be a threat in the red zone,” Crabtree said, “and he trusted me today.

I’m out there playing,” he said of the matchup with Peterson. “I don’t see no names.”