Officials in Seattle on Friday approved the nation’s first “safe-injection” sites for users of heroin and other illegal drugs, calling the move a drastic but necessary response to an epidemic of addiction that is claiming tens of thousands of lives each year.

The sites — which offer addicts clean needles, medical supervision and quick access to drugs that reverse the effects of an overdose — have long been popular in Europe. Now, with the U.S. death toll rising, the idea is gaining traction in a number of American cities, including Boston, New York City and Ithaca, N.Y.

While opponents say the sites promote illegal drug use, supporters say they can keep people alive and steer them toward treatment. They compare supervised injection facilities to the needle exchanges that became popular in the 1980s and 1990s as a way to stanch the spread of HIV and hepatitis C among intravenous drug users.

“These sites save lives and that is our goal in Seattle/King County,” Seattle Mayor Ed Murray (D) said in a statement.

The sites are not currently legal under federal law, according to Kelly Dineen, a professor of health law at Saint Louis University School of Law. A provision of the Controlled Substances Act makes it illegal to operate facilities where drugs are used, she said.

In addition to heroin, the deaths are caused by powerful prescription painkillers and fentanyl, a synthetic opiate so potent a tiny amount can kill people within minutes — leaving little time for help to arrive.

“If you want to really bend this curve of death, [safe injection sites are] going to have to be part of the strategy,” said Jessie Gaeta, chief medical officer of the Boston Health Care for the Homeless Program, which treats many victims of overdose.

In Seattle, the King County Board of Health voted unanimously earlier this month to endorse two sites, one to be located in the city and the other to be located in the surrounding county. Murray and King County Executive Dow Constantine (D) gave them final approval Friday. In 2015, 132 people died of heroin overdoses in the county.

“We see this as a public health emergency,” said Jeff Duchin, the health officer for Seattle and King County. “Clearly the status quo isn’t working anywhere, and clearly we need to look at new tools.”

Duchin said officials hope to open the Seattle site within a year. Both sites will be aimed primarily at homeless drug users, he said, with a goal of providing them basic health services and ultimately drug treatment.

“The real goal is not to open a day spa where people can come in and have a good time and use drugs, but to engage them in treatment,” Duchin said. “They inject in a place where there’s a health-care worker who can save their lives if they overdose.”

Duchin said all drug users will be supervised at all times. If a person exhibits signs of an overdose, he said, a health-care worker will administer Naloxone, a drug that reverses the effects of opioids.

Over the next three years, officials plan to study the sites and collect data on how many people they attract, whether overdose deaths are being prevented and whether users of the sites enter drug treatment.

Possession of heroin is illegal under federal law, but, Duchin said, “We’re not really seeing this as a legal problem right now. If there are legal issues that come up, we’ll have to address them.”

The Justice Department did not respond to a request for comment.

King County Sheriff John Urquhart (D) has been supportive of the idea, though he said the “jury is still out” on whether the sites will reduce the number of overdoses. He said his deputies will not arrest anyone coming or going from the sites, but he warned that the federal government “could camp out in front of the site and arrest anyone in possession.”

Meanwhile, the idea is running into opposition outside the city, with some suburban mayors making clear they are not eager to host one of the sites. State Sen. Mark Miloscia (R), who represents Federal Way, in the southern reaches of King County near Tacoma, introduced a bill barring safe injection facilities from opening anywhere in the state. It will have a hearing Monday.

“The people in my district, Democrat or Republican, would come unglued if we put a safe injection site in Federal Way,” Miloscia said. “Saving lives is about getting people off heroin and not tolerating it.”

Worldwide, at least 90 facilities have been created to permit people to inject illegal drugs under medical supervision. The first opened in Berne, Switzerland, in 1986. France opened its first facility in October. A supervised injection site in Vancouver, B.C., is the only such site in North America.

After that facility opened in 2003, researchers found that overdose deaths in the surrounding community dropped 35 percent in just two years. Still, British Columbia recorded 914 overdose deaths last year, up 80 percent from 2015.

Closer to home, the New York City Council last year appropriated $100,000 to study opening a safe-injection facility. San Francisco Mayor Ed Lee (D) dropped his longtime opposition to the sites, saying recently that he is now “open” to them.

And in Ithaca, N.Y., home to Cornell University, Mayor Svante Myrick (D) has been pushing to bring a site to his city. Myrick’s father suffered from drug addiction. He won a recommendation from a city task force last year.

That effort has since stalled amid rising opposition from the city’s police chief and state lawmakers. Cornell law professor William Jacobson has argued that the sites amount to a “government-run heroin shooting gallery,” though he recently acknowledged that the sites might help to prevent overdoses.

“The heroin scourge is real,” Jacobson said in an email. “I’m just not sure normalizing the use helps the problem.”

In Massachusetts, state Sen. William Brownsberger (D) recently introduced legislation to permit safe-injection sites throughout the state. Currently, Boston Health Care for the Homeless offers medical monitoring to people who have injected illegal drugs, but they are not permitted to use drugs onsite.

The program, which started in April, has 10 chairs where addicts can sit while a nurse monitors vital signs and administers Naloxone in case of an overdose. Gaeta said 400 people have used the facility 2,679 times. About 10 percent of them have gone directly from the room into treatment, a number she called “miraculous.”