SANTA CLARA, Calif. -- The midseason skid that looked as though it could derail the San Francisco 49ers season is firmly in the past.
After getting back to a successful formula of dominating on the ground, the Niners have won three straight games and again look like a contender in the NFC.
Deebo Samuel ran for two touchdowns before leaving with an injury and Elijah Mitchell rushed for 133 yards and a score, leading the 49ers to a 34-26 victory over the Minnesota Vikings on Sunday.
"We're all excited to be back in the mix and have the season in our control," defensive end Nick Bosa said. "We all knew we were a really good team. We had to execute better and now we're starting to execute at the right time."
The matchup between two .500 teams fighting for wild-card spots was a highly entertaining one with six scores in the third quarter alone, including a 99-yard kickoff return score by Minnesota's Kene Nwangwu.
But the 49ers (6-5) made just enough plays, including a fourth-down stop near the goal line midway through the fourth quarter to win their third straight following a stretch of five losses in six games.
"I think both of us are playing really good ball these last couple of weeks," Niners coach Kyle Shanahan said. "We have ground to make up and that's why we believed it would be like a playoff game. When two teams are playing inspired and have everything on the line, that's why it's a good football game for people to watch. It's not always the most fun tense-wise for everybody. But I'm proud of our guys and how they handled it."
Jimmy Garoppolo threw for 230 yards and a TD, but the Niners once again did more of their work on the ground with Samuel's two scores making him the first receiver since the merger to run for five TDs in a season. Samuel had six carries for 66 yards and also caught one pass for 15 yards before leaving with a groin injury that he hopes is not serious.
San Francisco finished with 208 yards rushing on 39 carries.
"They came with it," Vikings linebacker Erick Kendricks said. "We knew that their run game was really good. Very complex, very confusing. They have a lot of people to block and open up for it. It was about eliminating that and we didn't do it."
Kirk Cousins threw for 238 yards and two TDs to Adam Thielen for the Vikings (5-6). But he also had an interception that set up a short San Francisco scoring drive in the third quarter and couldn't connect with Justin Jefferson on the fourth down from the 3 after burning a timeout when he lined up under the guard instead of the center.
The Niners drove down into field-goal range, but Robbie Gould missed from 42 yards with 1:56 left and a chance to put the game away.
Minnesota drove to the San Francisco 38 before turning it over on downs when Cousins missed Jefferson on fourth-and-8.
The 49ers scored twice in a 22-second span of the third quarter starting when Samuel capped the first drive of the half with a 3-yard run.
Azeez Al-Shaair got an interception on the next play from scrimmage, capping Cousins' streak of 212 straight passes without an interception.
Mitchell ran it in from 6 yards on the next play.
The Niners used an 87-yard drive to tie the game late in the second quarter on Garoppolo's 3-yard pass to Jauan Jennings with 18 seconds left in the half.
The Vikings have allowed 66 points in the final two minutes of the first half, the most for any team through 11 games since at least 2000.
PLAYING FROM AHEAD
The Vikings scored on their second drive of the game when Cousins hit Thielen on a 2-yard pass on fourth-and-goal to take a 7-0 lead. That made Minnesota the 17th team in the Super Bowl era to take a lead of at least seven points in each of the first 11 games.
The first 16 teams to do it combined for an .852 winning percentage. The Vikings are the only team to do it and have a losing record.
Vikings: RB Dalvin Cook (shoulder) left after getting hurt in the third quarter when he lost a fumble. Cook will have an MRI on Monday. ... LB Anthony Barr (hamstring) also left in the third quarter.
49ers: LB Dre Greenlaw (groin) and RB Trey Sermon (ankle) left the game with injuries in the first half and didn't return. Greenlaw was back for his first game since injuring his groin in the season opener. ... LB Fred Warner (hamstring) left in the second half.
Vikings: Visit Detroit on Sunday.
49ers: Visit Seattle on Sunday.