MINNEAPOLIS >> The struggles Sam Darnold endured through his first five years in the NFL relegated him to backup duty last season with San Francisco, yet another prospect failing to perform like a premium draft pick.

He’s been quickly regaining his status in Minnesota.

Darnold passed for 268 yards and two touchdowns against his former team, including a 97-yard strike in the second quarter to Justin Jefferson, and an actively attacking defense again fueled the Vikings in a 23-17 victory over the 49ers on Sunday.

“Sam has been making a whole bunch of great decisions. We’ve got to just keep trusting in him to make those decisions,” Jefferson said.

Chief among those smart choices was to join the Vikings, who needed a veteran to stabilize the offense before turning it over to rookie J.J. McCarthy — who suffered a season-ending knee injury last month.

“The amount of work that goes into that position on your quarterback journey when everybody decides that you can not play — we always believed in him,” coach Kevin O’Connell said. “It felt awesome to watch him go do that thing.”

Darnold went 17 for 26 with one interception for the Vikings (2-0), who got three field goals by rookie Will Reichard and had 146 rushing yards.