SAN DIEGO — Fourth-and-29 at their own 37, 1:37 left in regulation and trailing by three points.

Game over for the Ravens?

Not so fast. After all, they were playing the Chargers, the masters of the come-from-ahead loss, and Ray Rice had the perfect play for the seemingly impossible situation.

“Check down, Hey Diddle Diddle, Ray Rice up the middle,” the Ravens running back said in describing the unbelievable play that helped the Ravens to a 16-13 overtime win against the staggering Chargers.

Six plays later, Justin Tucker kicked a 38-yard field goal to tie the game at 13 as regulation expired. Tucker made another 38-yarder with 1:07 left in overtime to win it.

But it was Rice’s 29-yard gain that saved the day and allowed the Ravens (9-2) to take an even firmer grip on the AFC North race.

Pushed back by a holding call against guard Marshal Yanda and a 9-yard sack of Joe Flacco by Antwan Barnes, the Ravens were down to their last desperate shot.

Flacco took a shotgun snap, looked downfield and then threw a short pass to Rice, who ran through a big hole in the middle of the field. Three Chargers missed him at the 50 before Quentin Jammer and Antoine Cason finally brought him down.

The ball originally was spotted at the 33. After a lengthy review, the ball was moved back to the 34 and the refs measured. The new spot still gave the Ravens a first down by the length of the ball.

“It was just total will,” Rice said. “Once I made the first guy miss when I cut back across the grain, I actually saw the defense had to flip their hip and I kept eyeing the first down. I looked and said, ‘Should I keep running to the sideline or should I just keep trying to get up field?’ And that’s what I did. I just kept getting up field.”

Said wide receiver Torrey Smith: “I had a great view. … That’s probably one of the best plays I’ve ever seen. You won’t see too many plays like that. He was the perfect guy for it.”

With the Chargers defenders playing deep, Flacco couldn’t find Smith open so he went to Rice.

“I thought it might be our best shot at the time — give it to Ray — and Ray made a great run and got a little lucky and it worked out perfect,” Flacco said.

All the Chargers had to do was get the stop and run out the clock for their first win against a team with a winning record this season.

“I don’t know what to say,” Jammer said. “A play like that should never happen. You can’t give them a chance to execute that play. But we had some breakdowns, for sure.”

Up to that point, San Diego’s defense had played well.

“It definitely upsets the stomach when things like that happen, but they happen,” said defensive end Corey Liuget, who had a sack, a big fourth-down stop earlier in the game and a pass deflection.

“You have to give a guy credit when he makes an awesome play like that. But it was big, the biggest of the game it changed the game. … Those kinds of plays are never acceptable in the NFL. You have to have somebody make the play.”

The Chargers (4-7) had gone ahead 13-3 on Nick Novak’s 30-yard field goal with 7:51 to go in regulation. This was the third time the Chargers blew a lead of double digits in the second half.