SANTA CLARA, Calif. (AP) A couple of late-game missed kicks proved to be the difference between making the playoffs and staying home last season for the Los Angeles Chargers.

With a chance to end this exhibition season on a winning note, Roberto Aguayo delivered and made his case to be the Chargers kicker when the season starts.

Aguayo kicked a 26-yard field goal on the final play of the exhibition season to lead Los Angeles to a 23-21 victory over the San Francisco 49ers on Thursday night.

''To hit a game-winner, it counts,'' Aguayo said. ''I'm glad our team was able to get up close and give me a shot.''

Aguayo is in a battle with Caleb Sturgis to win the kicking job for the Chargers (2-2) and got the opportunity for the winner against San Francisco. Coach Anthony Lynn had rotated his kickers during the game, with both making 36-yard field goals and extra points before Aguayo got the final chance after a 63-yard kick return by Detrez Newsome set up the winning drive.

''Both guys have kicked extremely well the last couple of weeks,'' Lynn said. ''It's been a healthy competition.''

It was a sweet moment for Aguayo, who was a second-round pick by Tampa Bay in 2016 but quickly flamed out. He missed nine field goals as a rookie and then was waived by the Buccaneers last summer. He made all three field goals this preseason.

''I feel like I've done great,'' he said. ''When I've had opportunities, I've done well. I'm really proud of myself from where I've come since last year. It's been a long road and a long journey.''

The kick spoiled a storybook night for San Francisco's Jack Heneghan. He was signed as an undrafted free agent out of Dartmouth as a camp arm for the Niners (1-3), joining the franchise his father, Lal, used to work for as a lawyer.

Heneghan got almost no snaps in team drills in practice this summer and didn't play in the first three exhibition games. But with most of the regulars sitting out Thursday, coach Kyle Shanahan gave him a chance and Heneghan made the most of it. He went 8 for 9 for 58 yards and ran twice for 17 yards to lead the two TD drives.

''I grew up watching the Niners, going to games back in Candlestick,'' Heneghan said. ''I've always been a big fan of the team. I would have been happy to have an NFL opportunity as a rookie anywhere. It was that much more exciting to do it at home in front of friends and family.''

Jeff Wilson scored on a 2-yard run and Jeremy McNichols had a 6-yard TD run with 2:58 to play.

Cardale Jones threw a 5-yard touchdown pass to Andre Patton , and Terrell Watson scored on a 4-yard run on the final play of the first half for the Chargers.

CAMEO APPEARANCES

While most of the regulars got the night off, two defensive starters got on the field for brief appearances for the 49ers. Defensive lineman Solomon Thomas had two tackles for losses on the opening drive before calling it a night. Thomas had missed time this summer with a concussion.

Linebacker Reuben Foster, who left last week's game with a concussion, played three series and knocked Detrez Newsome for a 6-yard loss after a catch. Foster will sit out the first two games with a suspension following two offseason arrests.

UNDER PRESSURE

Christopher Landrum had two sacks in the first half for the Chargers, including one that forced a fumble by Nick Mullens and set up a field goal for Los Angeles.

ROSTER PUSH

Seventh-round draft pick Richie James Jr. delivered another strong performance in his drive to make San Francisco's roster as a reserve receiver. He caught seven passes for 80 yards and added a 23-yard punt return. He finished the preseason with 15 catches for 192 yards and a TD.

''I'm a playmaker,'' James said. ''That's what I do. I come in and make plays when I get the ball in my hands.''

NATIONAL ANTHEM

All players on both teams appeared to stand during the playing of the national anthem.

INJURIES

Chargers: WR Artavis Scott left with an ankle injury.

49ers: FB Malcolm Johnson left with a foot injury.

NEXT UP

Chargers: Host Kansas City for season opener Sept 9.

49ers: Visit Minnesota for season opener Sept. 9.

---

More AP NFL: https://apnews.com/tag/NFLfootball and https://twitter.com/AP-NFL

Copyright 2018 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.