Justin Herbert threw two touchdown passes and ran for a score, and Dustin Hopkins kicked a 29-yard field goal with 2 seconds remaining, leading the Los Angeles Chargers to a 27-24 victory over the Philadelphia Eagles on Sunday.

Herbert threw for 356 yards, completing 32 of 38 passes. He got 1 yard on a sneak on fourth-and-1 from the Eagles 28 with 1:45 left, setting up Hopkins’ kick.

ALSO READ | NFL: Matt Ryan stars with 2 TD passes as Atlanta Falcons top New Orleans Saints

The Chargers (5-3) snapped a two-game losing streak. The Eagles (3-6) still haven’t won a home game in four tries under rookie coach Nick Sirianni.

The teams traded touchdowns on four straight drives in the second half before the final series.

Los Angeles went ahead 16-10 on Herbert’s 8-yard TD pass to Donald Parham Jr., but Hopkins missed the extra point. The Eagles quickly answered with Kenneth Gainwell running in from the 1 to take a 17-16 lead. Hurts completed 3 of 4 passes on that drive for 63 yards. He was 4 of 9 for 54 yards to that point.

ALSO READ | NFL: Le’Veon Bell’s 1-yard TD pushes Baltimore Ravens to victory against Minnesota Vikings

Herbert then ran in from the 8 and connected with Jared Cook on the 2-point conversion to make it 24-17.

But Hurts drove Philadelphia back down the field and fired a 28-yard TD pass to DeVonta Smith to tie at 24-24 with 6:07 left.

Smith had five catches for 116 yards. It was the second 100-yard game for the rookie and 10th overall draft pick.

Facing the NFL’s worst run defense, the Eagles took advantage. They had 176 yards rushing, including 62 from Hurts.

ALSO READ | Cordarrelle Patterson, the Falcons gadget player who is turning into fantasy darling

Herbert tossed a 2-yard TD pass to Stephen Anderson to give the Chargers a 7-0 lead late in the first quarter. Herbert drove the Chargers 98 yards on their first possession without scoring. His 1-yard pass to Keenan Allen on fourth down from the 2 turned it over on downs.

The Chargers again went on fourth-and-2 in the second quarter. Joshua Kelley was stopped after a 1-yard gain at the Eagles 26.