INGLEWOOD, Calif. — The analytics favored the Ravens going for it. Reality said it would have been disastrous had they not converted.

With Baltimore trailing the Chargers, 10-7, on Monday night in a critical AFC showdown at SoFi Stadium and facing fourth-and-1 from its 16-yard line late in the second quarter, coach John Harbaugh decided it was worth the risk.

After quarterback Lamar Jackson tried to draw Los Angeles offside before the two-minute warning, the Ravens went for it for real. Tight end Mark Andrews took the snap under center, running back Derrick Henry and fullback Patrick Ricard pushed from behind and Baltimore picked up 2 yards and the first down.

Three plays later, wide receiver Zay Flowers caught a short pass, cut back across the defense and gained 22 yards. Two plays later, Jackson threw deep down the left sideline for a well-covered Rashod Bateman, who fended off Kristian Fulton and hauled in the 40-yard touchdown strike.

That score gave Baltimore its first lead of the night as it shook off a sluggish start and turned the momentum in Harbowl III, with John Harbaugh’s Ravens pulling away against his younger brother Jim and the Chargers for a 30-23 victory.

The win keeps Baltimore (8-4) within a half-game of the first-place Pittsburgh Steelers in the AFC North. It also marked Harbaugh’s third victory over his sibling in as many meetings and the first since they last met in the Super Bowl in February 2013 when Jim Harbaugh was coach of the San Francisco 49ers.

The gamble late in the first half also was far from the Ravens’ last.

Clinging to a 17-16 lead late in the third quarter after both teams had traded field goals and facing fourth-and-1 from their own 39, they went for it again. This time the call was more traditional, and Henry ripped off a 27-yard gain.

Later in the drive and facing a fourth-and-1 from Los Angeles’ 25, Henry (24 carries for 140 yards) delivered again. Five plays later, Jackson hit Andrews in the back of the end zone for a 6-yard touchdown.

Rather than kick the extra point to extend the lead to eight points, however, the Ravens went for 2, but Jackson’s pass fell incomplete.

Unlike the Nov. 17 game against the Steelers, it didn’t matter.

After the Chargers (7-4) went three-and-out on their next possession, running back Justice Hill took a handoff on third-and-3 and raced around the left end for a 51-yard touchdown that extended the lead to 30-16.

It was a stark contrast to most of the opening 30 minutes and especially the first quarter. The Chargers dominated in both yards and time of possession in the opening frame, outgaining the Ravens 123 yards to 20 and keeping the ball for more than 10 of the first 15 minutes, and took a 10-0 advantage early in the second. But the Ravens finally started to chip away on both sides of the ball soon after.

On offense, they leaned on the long and strong legs of Henry, who came into the game second in rushing in the NFL and finally got going in the second quarter.

Off right tackle for 19 yards. Off left tackle for 14 yards. Then Jackson and Andrews ad-libbed to convert a third-and-5 before Henry ripped off another chain-moving run, this one for 11 yards.

A penalty for illegal formation on right tackle Roger Rosengarten wiped out Henry’s 5-yard touchdown run one play later, but Jackson made up for it by racing to the pylon for a 10-yard score.

That cut the deficit to 10-7, and the decision to go for it on fourth down from deep in their own end on the next possession paid off. Baltimore marched 93 yards in eight plays and was on its way.

Then the defense, which has been prone to giving up big plays and blowing big leads and was without All-Pro inside linebacker Roquan Smith because of a hamstring injury, did the rest.

The Chargers were held to just 10 points in the second half and quarterback Justin Herbert finished 21-for-36 for 218 yards but scored the game’s first touchdown on a 5-yard run.

It was also a disappointing night for ex-Ravens running backs J.K. Dobbins and Gus Edwards. Dobbins finished with 40 yards on six carries before suffering a knee injury late in the second quarter. He did not return. Edwards had just 11 yards on nine carries and a touchdown in the final minute.

Jackson, meanwhile, had just 177 yards but was efficient, completing 16 of 22 passes with two touchdowns and no turnovers. He improved to 18-4 in his career in games after a loss.

Have a news tip? Contact Brian Wacker at bwacker@baltsun.com, 410-332-6200 and x.com/brianwacker1.