(CNN) The San Francisco Department of Public Health has unanimously endorsed a task force's recommendation to open what could become the nation's first legal safe injection sites aimed at curbing the opioid epidemic.

The facilities provide a safe space where people can consume previously obtained drugs, such as heroin and fentanyl, under the supervision of staff trained to respond in the event of an overdose or other medical emergency. They also provide counseling and referrals to other social and health services.

Although the often-controversial facilities are not an ideal solution, they are a necessity in light of the skyrocketing number of deaths caused by opioid overdose in the United States, according to San Francisco Mayor Mark Farrell.

"I understand the misgivings around it and some of the rhetoric from people who don't support it," Farrell said last week. "But we absolutely need to give it a try."

More than 63,000 people in the US died from drug overdose in 2016, according to the US Centers for Disease Control and Prevention -- more than the number of Americans killed in the Vietnam War. At this rate, over half a million people will die from overdose in the US in the next 10 years, exceeding the number of Americans killed in World War II , the deadliest conflict in human history.

The city plans to open the first two facilities in July, the beginning of its fiscal year.

"I'm really excited," said Laura Thomas, the California state director for the nonprofit Drug Policy Alliance. "I've been working on this particular issue for over a decade."

There are an estimated 22,000 intravenous drug users in San Francisco, many of whom openly inject in public areas across the city. Last year, over 100 people died in San Francisco of drug overdose, according to a report published by the city's Safe Injection Services Task Force

More than 100 peer-reviewed studies on safe injection sites -- otherwise known as supervised consumption facilities -- have consistently shown them to be effective at reducing overdose deaths, preventing transmission of HIV and viral hepatitis, reducing street-based drug use and linking people to drug treatment and other services.

In addition to saving lives, the facilities are projected to save the city approximately $3.5 million a year in overdose related medical costs, according to Rachel Kagan, director of communications at the San Francisco Department of Public Health.

Other cities in the US, such as Seattle and Baltimore, are taking steps toward opening safe injection sites. Last week, Philadelphia announced that it will welcome private organizations interested in setting up such facilities.

But San Francisco will probably be the first to open one.

The operators of the first two facilities will be chosen from a list of six to eight nonprofit organizations that currently operate needle exchanges and other drug addiction services in the city, Kagan said.

Funding for the facilities will initially come from the private sector. According to Kagan, this helps the city avoid liability issues, since intravenous drug use is against state and federal law.

"There are over 120 of these around the world at this point, and they all operate on the same basic idea," Thomas said, referring to locations in Canada, Europe and Australia. "You show up; you check in; you use your drugs; you hang out for a while, interact with the staff and then go on your way."

site in Sydney managed 3,426 overdose-related events without a single fatality over a period of nine years, In Australia, a safe injectionsite in Sydney managed 3,426 overdose-related events without a single fatality over a period of nine years, according to a 2010 government report . The report also found that residents were half as likely to observe people injecting drugs in public at the end of the nine-year period.

"One of the biggest supervised injection facilities in the world -- certainly in North America -- is Insite in Vancouver, British Columbia," Thomas said. "There's a nurse's station in the middle of the room that has all of the syringes, sterile supplies that they may need, and then they go through the usual process of preparing their drugs and injecting them, all under the supervision of trained staff."

Supervised injection sites have faced opposition. Some believe that they implicitly condone drug use and lead to increased use. Opponents argue that there is no safe way to inject or otherwise use illicit drugs.

Though the sites in San Francisco would be at odds with California and federal laws, state legislators are trying to pass a bill that will protect anyone associated with the injection sites -- including property owners, employees and drug users -- from arrest. A version of the bill passed in the State Assembly last year but is two votes short in the state Senate, according to Thomas.

But the San Francisco sites will probably open this summer, regardless of changes to state law, she said.

Follow CNN Health on Facebook and Twitter See the latest news and share your comments with CNN Health on Facebook and Twitter.

"It certainly wouldn't be the first time that San Francisco has prioritized the health, safety and well-being of its residents over state or federal law," Thomas added. "Times have changed. The biggest threats we're seeing aren't crack houses in urban neighborhoods but overdose deaths and people injecting on the streets."

in January among 500 registered voters found that 67% of respondents backed the idea, while 27% opposed it and 6% didn't know. San Francisco residents are also generally supportive of the idea. A poll conducted by David Binder Research in Januaryamong 500 registered voters found that 67% of respondents backed the idea, while 27% opposed it and 6% didn't know.

According to the poll, more than half of all self-described progressives, liberals and moderates supported the idea, compared with 42% of self-described conservatives.