Nick Mullens, in his first NFL game, was the story of the final Battle of the Bay.

The 49ers’ third-string quarterback entered a prime-stage Thursday in anonymity and he exited with a stat line befitting his Hall of Fame buddy, Brett Favre, who gave him a congratulatory postgame phone call when Mullens was on the NFL Network set.

Mullens, a 2017 undrafted free agent from Favre’s alma mater, Southern Miss, completed 16 of 22 passes for 262 yards and three touchdowns in a 34-3 pounding of the Raiders at Levi’s Stadium. His 151.9 passer rating was the best by a QB in his first start with at least 20 attempts since the NFL-AFL merger in 1970, according to ESPN.

Before kickoff, Mullens wasn’t verified on Twitter, which gives a blue check mark to authentic accounts of notable people. During the game, as Mullens played verifiably well, he received his blue check mark.

“I think I’m here for a reason,” Mullens said, “and it was my opportunity to prove that I can play.”

Head coach Kyle Shanahan said he would “consider” Mullens remaining the starter when the 49ers host the Giants on Nov. 12.

Said Shanahan, smiling: “We were keeping our secret weapon ready to go.”

Mullens, 23, was an extremely well-kept secret: He hadn’t taken a regular-season snap before Thursday and was playing because backup C.J. Beathard, who was replacing the injured Jimmy Garoppolo, had a sprained right wrist. According to Shanahan, Mullens, who played in a spread offense in college, learned to take snaps under center after leaving Hattiesburg, Miss., by studying an instructional YouTube video.

However, Mullens’ teammates insisted his performance wasn’t completely jaw-dropping based on his maniacal preparation. Shanahan referred to Mullens as a “machine” based on the way he studies, and tight end George Kittle said Mullens is “literally more prepared than coach Shanahan” for games.

One story from Kittle: Mullens, at home, blasts crowd noise on his headphones and yells out plays to prepare for away games. Another: Last year, Mullens went on the field at Levi’s Stadium after a game and ran through plays by himself.

“That’s just Nick Mullens in a nutshell,” Kittle said.

Mullens, puzzled, confirmed the crowd-noise story, noting he finds the screaming soundtrack on Apple Music: “I don’t know how (Kittle) found that out because I only do it at my house, but it’s a good way to prepare.”

On Thursday, Mullens’ preparation met opportunity.

His first drive: Mullens completed 3 of 3 passes for 41 yards, with his final throw being a 24-yard touchdown pass on third down to all-alone wide receiver Pierre Garcon to give the 49ers a 7-3 lead.

3 notables DE Cassius Marsh: Had 2.5 of the 49ers’ eight sacks after he had one in their first eight games. TE George Kittle: Four receptions for 108 yards and a TD; his one-handed catch resulted in a 71-yard gain. RB Raheem Mostert: He had 86 yards on seven carries and a 52-yard TD run before leaving with a broken arm. — Eric Branch

Read More

His second drive: Mullens completed 6 of 8 passes for 62 yards and capped the march with a 4-yard throw to wideout Kendrick Bourne on 3rd-and-goal.

Then, on his first drive of the second half, Mullens put away the game. On the second play of the third quarter, he threw a 71-yard pass to Kittle, who made a one-handed catch in traffic and ran the final 58 yards. Two plays later, Mullens lobbed a 5-yard touchdown pass to an uncovered Kittle for a 24-3 lead.

“He had a couple of wide-open receivers early,” Raiders head coach Jon Gruden said, “and a couple of inexcusable errors by us.”

Mullens helped the 49ers (2-7) snap a six-game losing streak, but there should be a note of caution before Mullens-mania sweeps the Bay Area: He was playing against the Raiders.

Oakland (1-7), which is planning to leave for Las Vegas for the 2020 season, spent Thursday night as if its players’ minds were already in a different state.

The Raiders arrived with the NFL’s worst run defense, had the fewest sacks in the league and had allowed the second-most points per game.

Each of Mullens’ touchdown passes came to players in wide-open spaces and the receivers weren’t the only ones running free. With the 49ers leading 24-3 in the third quarter, Raheem Mostert, who later sustained a broken arm, wasn’t touched on a 52-yard touchdown run.

Shanahan, not meaning to take a shot at the Raiders’ defense, suggested Mullens wasn’t the only QB who could have flourished.

“I think C.J. would have played well tonight, too,” he said.

Instead, it was Mullens’ time.

On Wednesday night, when he knew he would be the starter, Mullens was asked how he slept.

“I slept good, except I woke up every hour,” he said to laughter. “But those hour periods were great.”

Then, on Thursday night, Mullens enjoyed a three-hour period that was far better than anyone expected.

In fact, it was verifiably great.

Eric Branch is a San Francisco Chronicle staff writer. Email: ebranch@sfchronicle.com Twitter: @Eric_Branch