CARSON, Calif. (AP) After all they've been through, a two-touchdown deficit wasn't going to faze the Los Angeles Chargers.

''We've been rock-bottom, so it's only up,'' running back Melvin Gordon said after the Chargers rallied for a 29-27 victory over the San Francisco 49ers on Sunday.

''We know how to respond when we go down. We always feel like we got the players to be in the game, regardless of how much someone goes up.''

Gordon played a significant part in the comeback, rushing for 104 yards on 15 carries to go with his seven receptions for 55 yards and a touchdown. It is the sixth 100-yard rushing game of Gordon's career and his first since last Oct. 29 against New England.

''He ran outstanding. There are some times when he could have gone out of bounds but he stayed between the yard lines and made plays,'' coach Anthony Lynn said.

Philip Rivers threw for 250 yards and three touchdowns as the Chargers improved to 2-2, the first time since 2015 that they are .500 after the first quarter of the season and a long way from their 0-4 start last season.

''It was good to see the resiliency of this team and how they bounced back. We played good, complementary football,'' Lynn said.

Gordon and Austin Ekeler averaged 5.6 yards per carry against a Niners defense that was 10th against the run and allowing only 97 yards per game. It is the first time in 11 games that San Francisco had allowed a 100-yard rusher.

''Gordon was playing very well. He opened up in the second half,'' 49ers linebacker Reuben Foster said.

The Chargers trailed 17-6 with 4:59 remaining in the second quarter then scored 20 straight points, including 11 in the final 47 seconds of the first half to tie it at 17 at halftime.

Caleb Sturgis had three field goals, including one from 21 yards with 7:41 left that gave the Chargers the lead, but he had an eventful day with two missed extra points.

C.J. Beathard, who got the start for San Francisco (1-3) after Jimmy Garoppolo's season-ending knee injury, was 23 of 37 for 298 yards with two touchdowns and two interceptions. The last interception came with 2:38 remaining when Isaac Rochell picked off a pass intended for Alfred Morris at the Niners 19. The Chargers then ran out the clock.

''I thought he played well,'' Niners coach Kyle Shanahan said. ''He played very tough. Made some great plays, especially in some of the situations. With a lot of guys going in and out, he handled a lot of adversity well and a little chaos due to injuries.''

Beathard's first TD toss of 2 yards to Kendrick Bourne gave the Niners a 14-0 lead with 3:53 remaining in the first quarter. His 82-yarder to George Kittle with 2:50 remaining in the third quarter helped end of run where they had three three-and-outs and an interception.

''It felt a lot more comfortable being out there and being in control. It definitely felt a lot more comfortable than last year,'' said Beathard, who lost five of six starts last season.

EXTRA-POINT WOES

The Chargers have missed eight PATs since the start of last season, which is the most in the league. Los Angeles has missed 10 extra points since the kick was moved back in 2015 and is one of eight teams in the league to have missed 10 or more.

VERSATILE BACKS

Gordon and Ekeler each caught touchdowns, the first time the Chargers have had two running backs catch touchdowns since Jacob Hester and Darren Sproles did it on Nov. 22, 2010, against Denver.

Ekeler's 22-yard reception on a go pattern drew the Chargers within 17-14 late in the second quarter. Gordon's 6-yard catch in the third quarter would give Los Angeles a 23-17 lead.

Rivers, who was 25 of 39, completed passes to eight players with Gordon and Ekeler combining for nine receptions and 81 yards.

MOVING ON UP

Rivers surpassed John Elway for the eighth-most yards in NFL history. He has 51,504 yards in his 15-year career while Elway had 51,475.

''Those are guys I had posters of on my wall, so just to be mentioned with them is definitely special,'' Rivers said.

HELD IN CHECK

San Francisco's Matt Breida came in tied for the league lead in rushing (295 yards) but he was held to 39 yards on nine carries.

Lynn said after the game that stopping the run was something they put extra emphasis on in practice all week.

INJURIES

Niners: Wide receiver Dante Pettis and left tackle Joe Staley suffered knee injuries. Staley's injury meant San Francisco had to reshuffle its offensive line, moving first-round pick Mike McGlinchey to left tackle and putting Garry Gilliam at right tackle.

Chargers: Wide receiver Travis Benjamin, who missed the past two games due to a foot injury, did not play during the second half. He had a catch for 2 yards. Left tackle Russell Okung did not play in the second half due to a groin injury.

---

Follow Joe Reedy at www.twitter.com/joereedy

---

More AP NFL: https://apnews.com/tag/NFL 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.