Jared Goff turned a phenomenal first half into the biggest game of his career, and it was still just barely enough to beat Kirk Cousins.

Goff passed for career highs of 465 yards and five touchdowns, winning a scintillating duel with his Minnesota counterpart and leading the unbeaten Los Angeles Rams to a 38-31 victory over the Vikings on Thursday night.

Goff hit Cooper Kupp with two of his four TD throws during a 251-yard first half in which the third-year quarterback flawlessly executed coach Sean McVay's offense.

"It was just great command by him," McVay said about Goff.

Todd Gurley then finished with 83 yards rushing and 73 yards receiving while the Rams (4-0) held off the Vikings (1-2-1) and Cousins, who passed for 422 yards and three touchdowns.

The Vikings got the ball back with 2:20 left, but Los Angeles rookie John Franklin-Myers stripped Cousins of the ball near midfield. The Rams recovered and ran out the clock on their first win in the franchise's last six meetings with Minnesota.

McVay was Cousins' offensive coordinator in Washington before he became Goff's head coach on the West Coast last season. McVay's current and former prize pupils put on a show at the Coliseum, but Goff finished 26 of 33 with a perfect 158.3 quarterback rating.

Goff picked apart the Vikings' secondary in the first half with one pinpoint throw after another. The former No. 1 pick has three consecutive 300-yard games during the Rams' perfect start.

Gurley and Brandin Cooks had first-half TD catches.

The Vikings trimmed LA's lead to 31-28 late in the third quarter with Adam Thielen's 45-yard TD catch and a 2-point conversion, but Goff promptly surpassed his previous career highs for yards passing during a swift drive ending in Robert Woods' 31-yard TD catch.

Both offenses came out firing at the Coliseum in front of a lively Coliseum crowd that included a healthy throng of purple-clad fans enjoying the Vikings' first game in Los Angeles since 1993.

One week after giving up 27 points in the first half and getting blown out as 16 1/2-point favorites in Buffalo, the Vikings gave up 28 before halftime against LA. They still hung in with one of the NFL's best offenses thanks to a dynamic game from Cousins, who hit Aldrick Robinson for two first-half scores.

Goff found Kupp with two beautiful TD throws in the first half, the first hitting Kupp in stride on a 70-yard sprint , and the second eluding two Vikings and dropping into Kupp's hands deep in the end zone.

"Jared put it in about a 6-inch box that only he could fit it into," McVay said. "He had great command and poise all night."

Less than 2 1/2 minutes later, Goff hit Cooks down the middle for a 47-yard score.

Both of those throws beat Minnesota cornerback Trae Waynes, who missed the second half with a concussion.

Goff's four TD passes were the most in a first half by a Rams quarterback since Kurt Warner did it in 1999.

Sam Ficken, the replacement for injured Rams All-Pro kicker Greg Zuerlein, kept it close by missing a 28-yard field goal with 8:21 to play.

Minnesota's Dan Bailey hit a 40-yard field goal with 3:46 left for the only points of the fourth quarter.