SAN FRANCISCO — Never in the 49ers’ celebrated history of offensive ingenuity and play-making prowess did they pile up as many yards as Alex Smith & Co. produced Sunday.

Never in NFL history had any team registered more than 300 passing yards and 300 rushing yards in a game.

Once they were done routing the Buffalo Bills 45-3, the 49ers owned a franchise-record 621 yards behind Smith’s precision passing, his receivers’ open-field bursts, an unstoppable rushing attack and superior blocking overall.

“Very cool, very cool,” Smith said of the record. “When you think of the 49ers, you think of great offenses, so this is quite an honor.”

Well, that’s what folks used to think, particularly in the Super Bowl-winning heydays behind coaches Bill Walsh and George Seifert, and quarterbacks Joe Montana and Steve Young.

These modern-day 49ers were historically balanced Sunday: 310 passing yards (303 by Smith, who was 18 of 24 with three touchdown passes) and 311 rushing yards (106 from Frank Gore).

Six players scored touchdowns, three via runs (Gore, Colin Kaepernick and Anthony Dixon) and three on Smith passes (Kyle Williams, Michael Crabtree, Mario Manningham).

“We’ve got so many weapons, and we work good together,” Gore said. “We’re just growing and having fun out there. I hope it keeps going like this.”

The 49ers’ scariest scene didn’t come until postgame, when Smith headed into Candlestick Park’s X-ray room, for what he called a sprained middle finger on his throwing hand. He suffered the injury on his final pass, a fourth-quarter incompletion to Vernon Davis, and Smith showed no signs of hindrance as he dressed after the game.

Sunday’s offensive output might not be an aberration, not when you consider the 49ers (4-1) produced 379 yards a week ago in a 34-0 shutout of another AFC East team, the New York Jets.

Of course, all that offense has been complemented by the 49ers’ trademark defense, in which turnovers are forced, running backs are stuffed and quarterbacks are disheveled. The Bills (2-3) were ripe for the rout, having allowed 45 second-half points last Sunday in a 52-28 loss to the New England Patriots.

Not since a 1961 win over the Chicago Bears had the 49ers pulled off this statistical feat: a 300-yard passer, 100-yard rusher and two 100-yard receivers, those being Crabtree (six catches, 113 yards) and Vernon Davis (five catches, 106 yards).

Add it all up and the 49ers eclipsed their previous all-time high of 598 yards, which also was set against the Bills, albeit back in 1992 when Young’s 449 passing yards couldn’t prevent a 34-31 defeat.

“That means something to the fellas,” 49ers coach Jim Harbaugh said. “They did a heck of a job, and they earned that by throwing, catching, rushing and protecting the football.”

From there, Harbaugh summoned offensive coordinator Greg Roman to the podium to take a bow.

Shortly after Roman preached his goal to keep the 49ers offense diverse and unpredictable, right guard Alex Boone put into perspective Roman’s play-calling role:

“He’s an evil genius, and I love the things he calls up.”

Smith tallied 237 passing yards before halftime, and while he emerged with his third career 300-yard game, it was his first in winning fashion. Fittingly, it put his starting record over .500 for the first time in his career (36-35).

Smith capped his first-half show by putting the 49ers ahead 17-3 on a 28-yard touchdown pass to Crabtree. That gave Smith a perfect 158.3 passer rating at halftime (12 of 15 passes with two touchdowns, no interceptions and, for good measure, no sacks).

Smith occasionally gave way to Kaepernick for the newfound “WildKap” formation, and Kaepernick delivered a 16-yard touchdown run with 9:55 remaining to give the 49ers a 38-3 cushion.

The 49ers were poised to put up more points just before halftime, but Kaepernick fumbled at the end of a 6-yard run inside the Bills’ red zone.

Three snaps later, however, the 49ers forced one of two Bills’ turnovers, as Patrick Willis stripped Scott Chandler of a reception. Dashon Goldson recovered for the 49ers at the Bills’ 28 with 29 seconds left in the first half, and Crabtree promptly produced his first touchdown catch this season.

Two weeks ago, the 49ers were humbled by a 24-13 loss at Minnesota. Since then, they’ve outscored two opponents 79-3, combined for 1,000 yards of offense and gained lots of momentum for next Sunday’s visit by the New York Giants, who beat the 49ers here in last season’s NFC Championship game.

“The big test will be next week,” Crabtree said. “We did good today, but we’re looking forward to next week.”

For more on the 49ers, see Cam Inman’s Hot Read blog at blogs.mercurynews.com/49ers. Follow him on Twitter at twitter.com/CamInman.