Surveillance video shows a San Diego police officer fatally shooting a transient seconds after the officer left his patrol car as the man walked toward him.

The video released by the San Diego County district attorney Tuesday shows police officer Neal Browder driving a short distance in an alley with his lights on and his door open before leaving the car.

Fridoon Rawshan Nehad, 42, was shot about four seconds later about 17 feet from the officer.

District Attorney Bonnie Dumanis defended her decision last month not to prosecute Browder at an hour-long news conference. She cited witness accounts that Nehad had a knife and released other surveillance video that doesn't show the shooting but that she said portrayed Nehad as a threat.

The object he was carrying turned out to be a blue metallic pen.

"The officer didn't have time to assess whether or not it was a pen or knife," Dumanis said at the hour-long news conference. "In the heat of the moment, when things are fluid, you can't take the chance that it's going to be something."

Skip Miller, an attorney for the Nehad family, said the video of the April 30 killing showed it was unprovoked. The incident is being investigated by the FBI.

"All you have to do is look at it," Miller said. "It shows a guy sort of ambling along, minding his own business, not engaged in any criminal activity."

Browder, a 27-year San Diego police veteran, was wearing a department-issued body camera but it was not recording at the time. He told investigators he didn't recall issuing any commands before firing, but a witness told investigators that Browder told Nehad to drop a knife.

The shooting drew attention after a nearby business captured the episode on surveillance video, which it turned over to police and declined to share publicly. The government gave the video to Nehad's family on condition they not release it.

U.S. District Judge William Hayes cleared the way last week for the family to release the video but put the ruling on hold until Wednesday to give the city and the police officer time to appeal. Dumanis got a one-day jump on the family, saying she was not bound by the order.

The city and the officer — the defendants in a wrongful death lawsuit — had opposed the release, saying it could taint a police investigation and the ongoing lawsuit. Dumanis said the defendants had indicated they wouldn't appeal the move to make the video public.

The San Diego Union-Tribune, Voice of San Diego, KGTV-TV, KPBS and inewsource had asked the judge to allow the video to be released.

Nehad was raised in war-torn Afghanistan, where he was drafted into the army and captured by rebels, according to his family's claim. He was held captive for two months, until his mother successfully pleaded face-to-face with the captors to release her son.

Nehad spent 14 years in Germany and came to the United States in 2003 to rejoin his family, which had settled in San Diego. The family says he has suffered post-traumatic stress disorder and been diagnosed with schizophrenia and bipolar disorder.

Laura Duffy, the U.S. attorney in San Diego, said her office, the FBI and the Justice Department's civil rights division were investigating the shooting. She declined further comment.