CHARLOTTE, N.C. — Matthew Stafford threw a 19-yard go-ahead touchdown pass to Colby Parkinson with 38 seconds left to lift the Los Angeles Rams to a dramatic 34-31 wild-card round win over the Carolina Panthers in the opening game of the NFL playoffs Saturday.

Stafford finished 24 of 42 for 304 yards with three touchdown passes and an interception, and Puka Nacua had 10 receptions for 111 yards and two total touchdowns as the Rams (13-5), who were 10 1/2-point favorites, advanced to the divisional playoffs.

Bryce Young threw for 264 yards and a touchdown and ran for another score for Carolina (8-10), which finished the season losing four of its final five games. Jalen Coker had career highs with nine receptions for 134 yards with a touchdown and Chuba Hubbard ran for 46 yards and two touchdowns.

The Panthers fell behind 14-0 early but stormed back to take a 24-20 lead on Hubbard’s second touchdown of the run game early in the fourth quarter.

Stafford, who was selected as an All-Pro earlier in the day, led the Rams back down on the field and found Kyren Williams for a 13-yard touchdown strike over the middle for a 27-24 lead.

Los Angeles appeared to be in charge after getting a stop on defense giving Stafford the ball back.

But a holding penalty put the Rams behind the sticks and forced a punt, which Isaiah Simmons blocked to set the Panthers up the Rams 30.

Four plays later, Young found Coker in the left corner of the end zone for a 7-yard scoring strike to give Carolina a 31-27 lead 2:39 left, sending the home crowd into a frenzy.

But Stafford quickly moved the Rams 71 yards in seven plays with Panthers two-time Pro Bowl cornerback Jaycee Horn on the sideline with a concussion, finishing it off with a perfectly placed pass to Parkinson near the right side of the goal line. Parkinson, who had two TDs last week, forced his way into the end zone for the score.

“Yeah, total team effort,” Stafford said. “Obviously, had some mistakes along the way. I turned it over, we had a punt blocked, didn’t score before the half when we probably should have. So, a lot to clean up, but found a way to win it late. I believe in my teammates. I know they believe in me.”

It was nearly the second time this season the Rams lost to the Panthers as a 10 1/2-point favorite. Carolina won 31-28 on Nov. 30.

Carolina’s last attempt to move into field-goal range ended when Jimmy Horn dropped a fourth-down pass from Young.

After the Rams defense came up with a stop on fourth down at midfield on Carolina’s opening drive, Stafford quickly moved the offense downfield and found Nacua for a 14-yard touchdown pass over the middle for a 7-0 lead.

Nacua made it 14-0 on a 5-yard run following Young’s interception.

Carolina cut the lead 17-14 at halftime after a 1-yard touchdown run by Hubbard and a 16-yard scramble by Young, the second-longest TD run of his career.

The Rams had a chance to build on the lead, but Nacau dropped a potential third TD on a pass down the right sideline from Stafford just before halftime.