Police fatally shot an armed robbery suspect, who appeared to fire at officers from inside the trunk of a car, during a brief but tense standoff Tuesday night in San Francisco’s Mission District.

The deadly exchange of gunfire came shortly after police said two armed robbery victims flagged down uniformed officers around 10:35 p.m. at 20th and Capp streets.

Officers said they quickly found the suspect vehicle, a black Honda Civic, one block down Capp Street near 21st and ordered everyone out.

The driver got out of the car and was detained at the scene, police said, but the officers soon noticed that the car’s trunk was ajar and someone was inside. More police arrived and surrounded the vehicle.

Witnesses described hearing officers command the suspect in Spanish to surrender while speaking over a megaphone.

Several residents in apartments along the block captured cell phone videos of the encounter. In the videos, a police officer is heard ordering the suspect out of the trunk before a single shot rings out. Seconds later, a barrage of gunfire begins and bullets are seen ripping into the rear of vehicle.

One witness caught the incident on video in close-up detail. The suspect is seen pushing the trunk open and firing at least two shots at police before officers return fire.

The witness declined to give his name to The Chronicle at the scene Wednesday morning but said he sold the video to KPIX-TV for $200.

After the shooting stopped, police found a third suspect, a woman, alive inside the vehicle. The man in the trunk, who was not immediately identified, was pronounced dead at the scene. No officers were injured in the shooting.

Police said they found a handgun in the trunk of the vehicle and investigators were interviewing the surviving suspects and other witnesses.

Capp Street was closed off at 21st through Wednesday morning while investigators processed the scene.

Dozens of police evidence markers covered the street, many marking shell casings. Some residents reported broken windows near where the shooting happened.

The barrage of police gunfire startled many of the residents taking cover inside their apartments.

“My first reaction was making sure my friends and neighbors were OK,” said a 24-year-old man who lives on Capp near 21st but declined to give his name. “I just heard it escalating and then all the shots.”

The shooting is being investigated by multiple agencies, including the SFPD’s Homicide Detail, the San Francisco district attorney’s Independent Investigations Bureau, the San Francisco Department of Police Accountability, the SFPD Internal Affairs Division and the Office of the Chief Medical Examiner.

The incident marks the first fatal officer-involved shooting in San Francisco this year, though police were involved in a February shooting where the suspect was uninjured.

That man, Joel Armstrong, a 31-year-old transient and murder suspect, was holed up inside an RV on a residential street in Mission Bay when the shootout occured.