BALTIMORE (AP) — Neither rain, wind nor the San Francisco 49ers’ top-ranked defense could prevent Lamar Jackson from guiding the Baltimore Ravens to their franchise-record eighth straight win.

Jackson weathered miserable conditions to run for 101 yards and Justin Tucker kicked a tiebreaking 49-yard field goal as time expired to give the Ravens a 20-17 victory Sunday in a possible Super Bowl preview.

The combination of driving rain, a stiff wind and San Francisco’s rugged defense was difficult for Jackson to handle. He completed only 14 of 23 passes for 105 yards and lost a fumble.

Asked afterward to describe the weather, Jackson bowed his head, lifted it slowly and peeked over the podium to declare, “Horrible.”

Certainly, not the kind of weather that benefited the passing game.

“Oh, man. I was throwing passes behind my receivers. It was ticking me off,” Jackson said. “A lot of passes getting away from me. The weather, it messed with me a lot.”

But the double-threat quarterback was solid when it counted. Not only did Jackson fuel the NFL’s top-ranked rushing attack, but he directed a clutch drive that lasted nearly 6½ minutes before Tucker ended it with a kick that tore through the raindrops and between the uprights.

Jackson knew that after he had done his job, Tucker would do his part.

“That golden leg. I got all the faith in him,” Jackson said. “I'm on the sideline praying, but at the same time I know Tucker can do it.”

Tucker, the most accurate field goal kicker in NFL history, now has 15 game-winners over an eight-year career.

“That’s the guy you want in that situation,” coach John Harbaugh said.

Baltimore (10-2) improved to 16-3 with Jackson as a starter and 12-0 when he rushes for at least 70 yards. In addition, Jackson became the first quarterback in NFL history to have four 100-yard rushing games in a season.

Raheem Mostert ran for a career-high 146 yards and a touchdown for the 49ers (10-2), now tied with New Orleans for the best record in the NFC.

“We had every chance to win that game. Came up a little bit short there at the end,” coach Kyle Shanahan said. “Credit to them. Hopefully, we can earn an opportunity to maybe get the chance to play them some other time again.”

Jimmy Garoppolo went 15 of 21 for 165 yards for San Francisco.

Jackson lost a fumble for the first time this season when Marcell Harris yanked the wet ball from his grasp at the San Francisco 20 in the third quarter.

The 49ers subsequently got a game-tying 32-yard field goal from Robbie Gould, who missed the previous three games with a quad injury.

In the fourth quarter, both teams failed to convert on fourth down before the Ravens faced a fourth-and-1 from their 44 with 4:39 left. Jackson ran off right guard for 3 yards to extend the drive.

A 12-yard pass to tight end Mark Andrews gave Baltimore a first down at the San Francisco 39, and the Ravens soon summoned Tucker to end it.

Mostert ran for 89 yards before halftime — surpassing his previous career high in a game — but Gould missed a 51-yard field-goal attempt as time expired in a second quarter that ended with the Ravens ahead 17-14.

33-yard touchdown pass from Garoppolo to Deebo Samuel concluded San Francisco’s first drive and made the 49ers the first team to score in the first quarter against Baltimore since the Bengals on Oct. 13.

It was also the first time the Ravens trailed since the second quarter of their game at Seattle on Oct. 20.

Baltimore tied it with a 20-yard pass from Jackson to Andrews after Garoppolo lost the ball while being sacked. It was the Ravens’ 48th touchdown of the season, breaking the franchise mark set by the 2009 team.

Jackson scored on a 1-yard run before the 49ers pulled even on Mostert’s 40-yard sprint to the end zone.

But San Francisco managed only 119 yards and three points after halftime.

“On offense, we were beating ourselves,” Mostert insisted. “It’s not like they were beating us down. … We just got to keep our heads up.”

FAKED OUT

During Baltimore’s second touchdown drive, Jackson put a move on K’Waun Williams that caused the cornerback to stagger to his right and fall down as the quarterback blew past him during a 7-yard run.

INJURIES

49ers: S Jaquiski Tartt left in the third quarter with a rib injury. ... DL D.J. Jones left in the third quarter with an ankle injury. ... RB Matt Breida (ankle) was inactive, missing a third straight game.

Ravens: LB Patrick Onwuasor left with an ankle injury in the third quarter but returned.

UP NEXT

San Francisco faces New Orleans on the road, the 49ers’ third straight game against a first-place team.

Baltimore travels to Buffalo for a matchup with the Bills, who beat Dallas on Thanksgiving and have the inside track on an AFC wild-card berth with a 9-3 record.