DETROIT -- Crucial throws by Matthew Stafford. A go-ahead field goal with under two minutes to play. A game-sealing interception.

The Detroit Lions are living dangerously but they've discovered a winning formula. Their 31-28 victory over the Los Angeles Rams on Sunday at Ford Field was nearly a carbon copy of their triumph over the Philadelphia Eagles a week earlier.

This time, Stafford threw four touchdown passes and Matt Prater kicked a tie-breaking 34-yard field goal with 1:29 remaining. Rafael Bush's interception with 1:02 remaining sealed the victory.

Detroit's 24-23 win over the Eagles included three Stafford touchdown passes, a go-ahead field goal by Prater with 1:28 left and a clinching Darius Slay interception.

Lions coach Jim Caldwell would prefer an easier path to success.

"We don't like to have them end that way but when we're right in the middle of it, it's always great to be able to come out on top in that regard," he said. "But we can't go to the well too often in those situations."

Detroit (3-3) also made a fourth-quarter comeback in its opening-day win at Indianapolis.

"I don't think any situation is too tough for us," Stafford said. "Whether it's Week 1 in that situation that we had to come from behind and win, or these late fourth-quarter comebacks that we had these last couple weeks, we just seem to rise to the occasion and play really well."

Stafford completed 23 of 31 passes for 270 yards. Golden Tate caught eight passes for 165 yards and a touchdown, while Anquan Boldin contributed eight receptions for 60 yards and a score.

The Lions were down to their third-string running back and third-string tight end entering the game, but still netted 348 yards without a turnover.

"We had our meeting last night and said, 'It's all hands on deck,'" Stafford said. "We're not sitting there as healthy as you can be with a bunch of guys. If you had a uniform today, you were playing. We knew it was going to be that way and we rose to the occasion. We're banged up in spots but we're making plays."

Los Angeles quarterback Case Keenum completed 27 of 32 passes for 321 yards and three touchdowns but also threw the late interception. Keenum connected on 19 consecutive passes at one point. Kenny Britt had seven receptions for 136 yards and two touchdowns but Todd Gurley was held to 58 rushing yards on 14 carries for the Rams (3-3).

"Our defense has got to play better than that," Rams coach Jeff Fisher said. "Thirty-one points is not acceptable, especially in a game where your offense is starting to click and you're making plays and scoring points."

Stafford's 61-yard pass to Tate, a free play because the Rams were flagged for jumping offside, set up a 4-yard scoring pass to Boldin, giving Detroit a 21-14 lead in the third quarter.

Keenum's 18-yard scoring pass to tight end Lance Kendricks midway through the quarter tied it. Britt's 47-yard reception highlighted that drive.

Britt fought his way into the end zone on a 9-yard scoring pass from Keenum in the opening minute of the fourth, lifting the Rams to a 28-21 lead.

Keenum's yardage total was the second-highest of his career.

"Case was feeling good today," Fisher said. "It slowed down for him. He made some big-time throws. I was pleased with the way Case played but we still didn't win the ballgame."

The Lions came right back with an 84-yard drive that Stafford finished off with a 23-yard pass to Tate.

After forcing a punt, Detroit drove 44 yards to set up Prater's 12th game-winner.

Bush then intercepted a Keenum pass intended for Kendricks, ending the Rams' final drive after two plays with 1:02 left to clinch the Lions' win.

The game was tied at 14 at halftime.

Los Angeles went for a touchdown on 4th-and-goal from the 1 on the final play of the half but that decision backfired. Gurley was tackled for a loss by backup defensive tackle Stefan Charles.

NOTES: Lions RBs Theo Riddick (ankle) and Dwayne Washington (ankle, DT Haloti Ngata (shoulder), LB DeAndre Levy (quad), G Larry Warford (hip) and TE Eric Ebron (ankle) were inactive. The Rams played without DE Robert Quinn (shoulder( and CB Trumaine Johnson (ankle). ... The last time an NFL team from Los Angeles played in the city of Detroit was 1971, when the Rams defeated the Lions 21-13 at Tiger Stadium. ... The Rams head to London to face the New York Giants next Sunday morning, while the Lions finish off a three-game home stretch against Washington. ... Detroit honored its 1991 team, the last to record a playoff victory, during a halftime ceremony.