SAN DIEGO - In a game full of crazy twists and turns, Marcus Gilchrist had the capper.

The strong safety intercepted journeyman Shaun Hill at the goal line with 56 seconds left to preserve the San Diego Chargers' 27-24 victory against the St. Louis Rams on Sunday that helped tighten the AFC West race.

Gilchrist jumped the route as Hill tried to force a pass to Kenny Britt, who also was covered by Shareece Wright, on second-and-goal from the 4.

Hill had beaten Gilchrist on a 7-yard TD pass to Stedman Bailey with 2:04 left that pulled the Rams within three points.

"My man didn't really do too much, so I just looked back at the quarterback and I saw a crossing route coming up ad I was able to go at it," Gilchrist said.

His immediate reaction?

"Thank you Lord," Gilchrist said. "It's one of those plays that as a kid you dream of. In basketball you want to make the game-winning shot, and in football you want to make the game-winning play, somehow."

The Chargers (7-4) won their second straight game after a three-game losing streak. They pulled into a second-place tie in the AFC West with Kansas City, which lost at Oakland on Thursday night. Denver rallied to beat Miami and leads the division at 8-3.

"They had good coverage on my primary, and Kenny just kind of flashed and I pulled," Hill said. "It was just a reaction.

"The coaches put the ball in my hands with a chance to win the game, and I appreciate that," Hill said. "I let them down. There's no way you can sit there and second-guess the play calling. If you're going to second-guess anything, second-guess the guy who didn't execute the play, and that's me."

The Rams had two touchdown passes nullified by penalties, although they ended up scoring on one of those drives, and had a field goal attempt blocked.

"The plan was not to go down there and settle for a field goal. We were trying to win the game," coach Jeff Fisher said. "It's not Shaun's fault. He got us there. He made some big throws earlier that kept us in the game."

St. Louis got the ball back at the Chargers 40 after a long punt return by Tavon Austin and a 27-yard pass from Hill to Britt gave the Rams the ball at the 6. Benny Cunningham gained 2 yards before Hill was intercepted.

The Rams (4-7) were trying for consecutive wins for the first time this season, having upset Denver a week earlier.

Ryan Mathews had a 32-yard touchdown run and linebacker Andrew Gachkar scored on a 13-yard fumble recovery 21 seconds later for the Chargers.

Philip Rivers shook off a 99-yard interception return for a touchdown by Janoris Jenkins and threw a 29-yard touchdown pass in the fourth quarter to Keenan Allen, who earlier had two turnovers. Rivers, playing with sore ribs, completed 29 of 35 passes for 291 yards.

The Chargers' third-quarter outburst started when Mathews took a delayed handoff and picked his way up the middle to cap their first possession of the second half for a 13-10 lead. It was his first touchdown since opening night. Mathews sprained his right knee in Week 2 and missed the next seven games.

On the second play of the ensuing Rams drive, Chargers end Corey Liuget hit Hill as he was trying to pass, knocking the ball loose. Gachkar alertly swooped in, picked up the ball and scored for a 20-10 lead.

Gachkar seemed to be the only player who realized it was a fumble.

"It was pretty lucky," Gachkar said. "I basically blacked out once I picked the ball up because I hadn't scored since high school. I had no energy after it because my entire team basically hit me celebrating. It was pretty cool."

The Rams benefited from a fumbled punt when Chargers returners Allen and Chris Davis collided after Allen called for a fair catch, with Alex Bayer recovering. Austin scored on a 6-yard score on an end-around to pull the Rams to 20-17.

Allen then fumbled after a reception and long run, with St. Louis' Rodney McLeod recovering.

Allen caught a screen pass from Rivers and picked his way through the defence to give San Diego a 27-17 lead with 8:09 to play.

The Chargers had a third-and-goal from the Rams 8 early in the second quarter when Jenkins outmuscled Allen for the ball and outraced everyone down the field to give the Rams a 10-3 lead.

NOTES: Mathews briefly came out of the game with a shoulder injury but returned. ... Chris Watt, a rookie from Notre Dame, had his first NFL start and was the fourth player to start at centre for the Chargers this season. ... Allen had six catches for 104 yards. ... Hill, making his second straight start, was 18 of 35 for 198 yards. ...

___

Follow Bernie Wilson on Twitter at http://twitter.com/berniewilson

___

Online: http://pro32.ap.org/poll and http://twitter.com/AP_NFL