The two officers, who have not been named, were responding to a report of a suspicious person with a gun at about 9:40 p.m. at Reardon and Kiska roads, Sgt. Troy Dangerfield said.
The officers were walking near a public housing development in the area when they came upon suspects who began shooting at them, Dangerfield said.
The officers identified themselves as police and returned fire, according to Dangerfield.
Neither the officers nor the suspects were hit by the gunfire, he said.
Three juvenile males and a man in his early 20s were taken into custody nearby, Dangerfield said.
The suspects, all San Francisco residents, are not being named -- the adult because of the ongoing investigation, and the boys because of their juvenile status, Dangerfield said. All four were booked on gang charges and one also on a firearms charge, he said.
An investigation is being conducted by the Police Department's gang task force and homicide unit. An internal affairs investigation is also being done, which is standard protocol when an officer discharges a firearm.