The legal action follows a similar lawsuit against the city of Chicago over its handgun ban, filed within hours of Thursday's high court ruling.
"Thursday's gateway ruling marks just a beginning, not nearly an end, to Second Amendment litigation," writes CBS News chief legal analyst Andrew Cohen. "We now will see dozens of challenges to existing gun laws, all designed to challenge the outer boundaries of the … ruling. And we quite likely will soon see another Supreme Court ruling on the topic. It's inevitable."
In San Francisco, the NRA was joined by the Washington state-based Citizens Committee for the Right to Keep and Bear Arms and a gun owner who lives in the city's Valencia Gardens housing project as plaintiffs.
The gun owner, who is gay, says he keeps the weapon to defend himself from "sexual orientation hate crimes." He was not identified in the complaint because he said he fears retaliation.
San Francisco City Attorney Dennis Herrera said the Supreme Court ruling didn't address gun bans on government property and that he was "confident that our local gun control measures are on sound legal footing and will survive legal challenges."
San Francisco also requires residents to keep guns in lockboxes or equip them with triggerlocks. That law, passed by the county supervisors last year, wasn't challenged in Friday's lawsuit.
A state appeals court has overturned a broader citywide gun ban passed by voters in 2005.
The Chicago lawsuit challenges its 1982 ordinance that makes it illegal to possess or sell handguns in the city.
NRA lawyer C.D. Michel said both lawsuits were necessary to expand the Supreme Court's ruling beyond Washington, a federal district, to states and cities.
"The Supreme Court decisions was very encouraging," Michel said. "But it is just a start."