Jared Goff passed for 292 yards and three touchdowns and the Los Angeles Rams outlasted the San Francisco 49ers, 41-39, on Thursday night in Santa Clara, Calif.

Todd Gurley ran for 113 yards and two scores for Los Angeles (2-1), who led 24-13 at halftime and 34-20 heading into the final quarter. The Rams needed a stop on the potential game-tying 2-point conversion late in the fourth quarter to preserve the win and avoid blowing a 15-point lead.

The Niners scored three fourth-quarter touchdowns, including Carlos Hyde’s 1-yard run with 2:13 left that drew them within two points. However, Los Angeles nose tackle Michael Brockers intercepted the ensuing conversion try to seal the victory.

Robert Woods caught six passes for 108 yards for the Rams, while teammate Sammy Watkins had six receptions for 106 yards and two touchdowns.

Brian Hoyer threw for 332 yards with two scores and an interception for San Francisco (0-3). Hyde added 84 yards rushing and two touchdowns. Adding in Hoyer’s rushing touchdown, the duo accounted for the first five times their team has crossed the goal line this season.