A 17-year veteran SFPD officer told investigators that he shot a 29-year-old woman on Thursday out of fear that his partner might be hit by the fleeing suspect’s car or he himself was going to be pinned against a nearby chain link fence, NBC Bay Area News has learned.

According to sources with direct knowledge of the investigation, the Thursday morning confrontation with Jessica Williams began when the sergeant spotted her behind the wheel of a stolen white Honda Accord at the end of a cul de sac near Interstate 280 in the Bayview. The encounter started where Elmira Street dog legs and turns into Helena Street.

The woman was parked next to another stolen car, where investigators later learned that her boyfriend was sleeping.

As the sergeant and the second officer approached, Williams drove away and down the hill. But she veered into a parked truck on the right side of the street. The sergeant rushed to the crash, and approached the Honda from the sidewalk. He again tried to take Williams into custody.

However, by the sergeant’s account, the woman drove forward and backward in an attempt to free her car from the crash with the parked truck. He told investigators he feared that she may pin him against a nearby chain link fence. He also told investigators that he feared that the car would hit a fellow officer rushing to the scene from the top of the hill.

That was when he fired one round from the sidewalk into the car, killing Williams.

Public Defender Jeff Adachi, a long-time critic of the department, cast doubt on the sergeant’s version of events, saying the department has a policy prohibiting officers from firing into vehicles unless the danger is clear.

“It’s ridiculous that this happened again,’’ he said, referring to a recent string of officer shootings, including the death of Mario Woods.

In the latest case, he said, the suspect “was in a car, it was moving back and forth, and the officer shot her. This is the precise type of situation where the officers should first figure out what the heck is going on, and there is really no need for them even to take out their weapons.”

Interim Chief Toney Chaplin said at a press conference Friday he expects to get a full briefing on the shooting and the department will release more details next week.