The 49ers had three touchdowns in the first half. The Lions had two and were stopped at the San Francisco 8 on another drive.
The Lions opened the second half with a 10-play, 66-yard drive to tie it up.
Jared Goff threw a 6-yard touchdown pass to tight end Sam LaPorta on third-and-goal, and Goff then hit Tim Patrick on a 2-point conversion. The game is tied 21-21.
The Lions now have outgained the 49ers 277 to 260.
Goff is 16-of-19 for 196 yards and two touchdowns.
Jameson Williams has two catches for 56 yards and a touchdown. He also has run for a touchdown.