SANTA CLARA, Calif. (AP) For all the talk of how dynamic San Francisco's offense could look with Christian McCaffrey and Deebo Samuel, it was the 49ers defense that once again led the way.

McCaffrey ran for the go-ahead touchdown with 7:54 to play, and the Niners pitched a second-half shutout to beat the Los Angeles Chargers 22-16 Sunday night in their first game back from a bye week.

''I was proud of our team today,'' coach Kyle Shanahan said. ''I want to play better. I want to blow people out. I want to score every time we go. ... Those guys are tough to get in the end zone against and they did that to us today. But we still found a way to win.''

The Niners (5-4) returned from the midseason break as healthy as they've been all season on offense and with hopes of making a second-half run. Their performance against the short-handed Chargers (5-4) was a slog at times but proved to be just enough to come out on top.

San Francisco fell behind by 10 points in the second quarter before rallying. Jimmy Garoppolo scored on a 1-yard sneak in the second quarter and then made the biggest play when he hit Brandon Aiyuk on a 24-yard pass on third-and-10 from the Chargers 26 midway through the fourth quarter.

McCaffrey ran it in on the next play and has now accounted for four touchdowns in three games since arriving from Carolina in a midseason trade.

Garoppolo went 19 for 28 for 240 yards while San Francisco relied heavily on the ground game, rushing 41 times for 157 yards, and defense.

''There's different ways to win this league,'' Garoppolo said. ''We definitely made it hard on ourselves, that's for sure. But a lot of resilient guys, a lot of mature guys. ... It wasn't pretty early on and they were doing some things that gave us trouble, but we stuck with it.''

Justin Herbert went 21 for 35 for 196 yards with a touchdown pass for the Chargers, who were playing without both starting tackles and receivers.

After scoring a touchdown on their opening possession, the Chargers managed just three field goals - two on drives that started in Niners territory - the rest of the way against a stout San Francisco defense.

''They did a good job against the run in the second half,'' coach Brandon Staley said. ''We couldn't get anything going in the run game, and in the passing game it was tight. The rush was coming, and there wasn't a lot of air in the second and third level to take advantage of.''

The Chargers failed on two late chances, They took over at their 1 with 2:03 to play but turned it over on downs when Herbert's pass on fourth-and-3 from his own 8 went off Joshua Palmer's hands for an incompletion.

After holding San Francisco to a field goal, Herbert got another chance with 53 seconds to go but was intercepted by Talanoa Hufanga on the first play to seal the game.

''It didn't go our way today,'' Herbert said. ''Unfortunately we fell short.''

San Francisco held the opposition scoreless in the second half for the second straight game after allowing 44 points to Kansas City in Week 8.

''We know that we're we're one of the best defenses in the league,'' linebacker Fred Warner said. ''We've shown that throughout the season. One bad game doesn't define you.''

FAST START

The Chargers flipped the script from their recent games, when they became the first team since 1988 to trail by at least 10 points following the first quarter in four straight outings. Herbert completed all four passes on the opening drive, capped by a 32-yard TD strike to DeAndre Carter.

Los Angeles then held the Niners to a field goal after a drive inside the 10 and led 7-3 after one.

EJECTED

Niners linebacker Dre Greenlaw was ejected late in the second quarter when he delivered a helmet-to-helmet hit on Herbert. Herbert was forced to leave the game to be checked for a concussion.

''It blew my mind,'' Shanahan said of the ejection.

Chase Daniel came in for the final three plays of the half. The Chargers' drive stalled and they settled for a field goal that made it 16-10. Herbert was cleared and returned at the start of the second half.

INJURIES

Chargers: DL Otito Ogbonnia (knee) and TE Gerald Everett (groin) left in the first half and didn't return. ... DL Christian Covington (pectoral) left in the fourth quarter.

49ers: WR Danny Gray rolled his ankle in warmups and didn't play.

UP NEXT

Chargers: Host Kansas City next Sunday night.

49ers: Play Arizona in Mexico City on Monday, Nov. 21.

---

AP NFL coverage: https://apnews.com/hub/nfl and https://twitter.com/AP-NFL

Copyright 2024 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.