The injunction prohibits some 40 people identified by police as members of the "Down Below Gangsters" and the "Towerside" gang from engaging in graffiti, vandalism, loitering and other gang activities within a safety zone mapped out by the city attorney's office.
Police believe the two gangs have been responsible for at least 10 murders in the past three years.
The zone covers less than two-tenths of a square mile which includes all of the Sunnydale Housing Development, the scene of numerous shootings over the years.
A police substation in the development was even shot up last fall during a gang shootout, slightly injuring an officer who was in the office at the time.
This is the fourth gang injunction issued by the courts against seven gangs in the past four years. The other court orders cover gang turf in the Bayview-Hunters Point, Western Addition and in the Mission.
City Attorney Dennis Herrera says most of the gang members don't even live in the city.
"You have people who are commuting into the city and county to carry out their illicit activity within the area of these safety zones," he said.
Statistics from the city attorney's office reveal that since the injunctions, almost half of the gang members have had no arrests in the city, but Bayview activist Nyese Joshua says the court orders are racially motivated.
"People are lulled into thinking that if you remove the public housing population that then somehow you will heal and remove them and all of the problems will be solved," he said.
Neighbors and merchants said they welcome anything that will stop the violence, but none would speak on camera for fear of reprisals.