San Francisco is in the middle of a drug crisis. Overdose deaths reached a record high last year, topping 800. Public drug use is widespread in some neighborhoods.

How did San Francisco get to this point? In part, it follows the national story: The rise of fentanyl, a synthetic opioid, and a destabilizing pandemic caused a spike in addiction and overdose deaths.

But San Francisco’s drug crisis has outpaced the country’s. In 2014, the city’s overdose death rate was roughly in line with the national average. As of last year, its rate was more than double the national average, and San Francisco was No. 4 for overdose deaths among U.S. counties with more than 500,000 people. The country’s overdose crisis worsened over the past decade as fentanyl spread, but San Francisco’s worsened much more quickly.

Local policy changes are partly to blame, some experts say. In 2014, California voters passed Prop 47, reducing drug possession to a misdemeanor from a felony. Different parts of the state have interpreted the change differently. In San Francisco, law enforcement has responded by scaling back efforts against drugs, de-emphasizing incarceration and effectively allowing public drug use.

Those who support at least partial decriminalization often cite the experience of Portugal, which decriminalized all drugs more than two decades ago and then saw a decline in drug-related problems. In 2019, the San Francisco district attorney at the time, George Gascón, even visited Portugal to learn more. But while San Francisco and other liberal cities have embraced some aspects of Portugal’s decriminalization laws, they have struggled to replicate Portugal’s success.

The comparison with Portugal is not perfect. For one, fentanyl has not taken over Portuguese drug markets, and has a relatively small presence in Europe as a whole. Still, the comparison gives a way to think about the challenges that San Francisco and other cities have faced. Those challenges can be broken down into five parts, each touching on a different aspect of drug policy.

What Portugal did: Decriminalization is widely misunderstood; it’s not full legalization, but removes criminal penalties for small amounts of drug possession. In 2000, Portugal passed a law that decriminalized all drugs, including heroin and cocaine. But it kept some penalties, like fines and license suspensions, to incentivize people to get addiction treatment and deter outdoor public drug use. If police officers catch someone using drugs, they can, and often do, still cite them.

Along with decriminalization, Portugal also invested in addiction treatment and created a system that tries to push people to seek help for addiction. “Decriminalization by itself means nothing if you have nothing else to offer,” João Goulão, the architect of Portugal’s system, told me.

What San Francisco did: California’s Prop 47 did not technically decriminalize drugs, leaving possession as a misdemeanor. But the police do not stop or otherwise intervene with drug users, even as they use in public view, and prosecutors rarely file charges for drug possession or use.

With a new district attorney as of mid-2022, the city started arresting more drug dealers and some users. But drug users still do not worry about arrests, and public use remains common. Residents often feel as if they have to check on drug users on sidewalks. “That’s how I found my first dead body,” said Adam Mesnick, owner of a deli in the South of Market neighborhood.

Mayor London Breed has tried to straddle the line between a focus on public health and law enforcement, while acknowledging the deteriorating situation. “While we want to get people the help they need, we can’t continue to allow drug dealing and public drug use to continue,” her office said in a statement.

What Portugal did: In Portugal, the government provides much of the treatment. It is largely voluntary, mostly free and readily includes medications (like methadone) that studies show are the most effective approach for opioid addiction. The system has faced some problems in recent years, particularly staff shortages and waiting lists. Dr. Goulão says those difficulties are a result of national disinvestment, as the country has dealt with debt crises.

Portugal also has a system to encourage drug users to get treatment, since refusing care is a common feature of addiction.

When people are cited for drugs, they are sent to so-called dissuasion commissions. The commissions talk with people — using techniques like motivational interviewing — to persuade them to stop using drugs and seek help. But the commissions also have the threat of penalties, including community service and the revocation of a professional license, to more forcefully push someone into treatment if persuasion fails. “There’s a little bit of muscle involved,” Dr. Goulão said.

What San Francisco did: San Francisco, California and the federal government fund addiction treatment. But the system is fragmented. Some providers offer medications for opioid addiction, while others reject medications as replacing one drug with another. Some treatment is effectively free or paid for by insurance, but other services can charge patients thousands of dollars or more. As a result, patients frequently struggle to find a treatment option that both works for them and that they can afford.

San Francisco also has trouble nudging people into treatment. In some cases, the city offers drug users the option of treatment as an alternative to jail or prison. But this is available only when an addict is charged with more serious crimes, like robbery, that carry jail or prison time. Drug use alone is not enough.

One program started by the city last year offers people treatment after they are charged with drug use or sales. But if the users refuse treatment, they are typically released anyway. From May 30 to Jan. 4, just 25 people accepted treatment after an arrest, in a city where tens of thousands of people use drugs regularly.

What Portugal did: Harm reduction prioritizes keeping people alive over getting them to stop using, an idea that gained prominence during the H.I.V. and AIDS crisis of the 1980s and ’90s. Portugal has widely adopted some harm reduction measures, such as needle exchanges. But the government made getting people into treatment its top priority, particularly through dissuasion commissions. (Local activists have criticized the government for not further embracing harm reduction approaches.)

Across the country, harm reduction services often act as a gateway to addiction treatment. Staffers at these services work with the treatment system to link clients to more help. “What we want is to provide citizens a way to change their life, if they so wish,” Dr. Goulão said.

What San Francisco did: San Francisco has become one of the biggest supporters of harm reduction, which has proliferated in the U.S. during the opioid crisis. The city has not just adopted traditional harm reduction strategies. It has also led the way on new ones, such as passing out straws and foil to reduce the chance of infection among people who use fentanyl.

San Francisco’s harm reduction programs don’t require staff to guide clients toward treatment. The programs argue that such pushiness could scare away clients who are not interested in quitting drugs.

Michael Discepola, director of health access at the harm reduction program GLIDE, said his organization was fine with clients continuing to use drugs as long as they did so in a way that the group saw as safe. Abstinence is not always the correct goal, he argued.

Can an approach focused so much on harm reduction work? Maybe, but its track record is not promising. British Columbia, in Canada, is a global leader in harm reduction. People can use drugs at supervised sites. Some programs prescribe and distribute opioids, including heroin, with the aim of providing a safer supply than what’s on the streets. Yet in 2023, British Columbia set a record for overdose deaths. Harm reduction policies probably reduce deaths, but they have not turned the crisis around.

What Portugal did: Portugal is a predominantly Catholic, somewhat socially conservative country that still by and large discourages and stigmatizes drug use. Though culture is a slippery and broad concept, experts say it is important (often pointing to the public health campaign against smoking as an example). The social attitudes in Portugal probably helped to deter drug use and encourage treatment even as the legal system eased up. “That certainly played a role,” Dr. Goulão said.

The country has taken steps to show compassion for addicts, including decriminalization, to make it easier for them to get help. But it continues to see drug use as socially damaging — a “love the sinner, hate the sin” philosophy.

What San Francisco did: San Francisco takes a more libertarian approach. Local activists often talk about drug use as a right — that people should be able to put what they want into their own bodies. They have also worked to destigmatize drug use, to make it easier for people to open up about it and seek help.

In early 2020, a downtown billboard showed happy young people seemingly enjoying a high together. “Know overdose,” the billboard said. “Do it with friends. Use with people and take turns. Try not to use alone, or have someone check on you.”

The billboard is no longer there, but to critics, it represented a school of thought that came close to loving the sin, or at least accepting it. San Francisco “is on the extreme of a pro-drug culture,” Keith Humphreys, a drug policy expert at Stanford, told me.

What Portugal did: The biggest challenge to addressing a drug crisis is making everything work together. In the 1990s, Lisbon was called the “heroin capital of Europe.” About 1 percent of Portugal’s population used hard drugs. Hundreds died each year, a large toll in a small nation.

Portugal’s now-famous response — decriminalizing drugs and funding new addiction treatment programs, harm reduction services and dissuasion commissions — came from changes in national laws that reflected a unified top-down plan.

In recent years, some drug problems have ticked up, as The Washington Post reported. But for the most part, the system remains. Portugal’s drug-related deaths are still a fraction of what they were in the 1990s. The country also has fewer such deaths, after accounting for population, than most of its European peers.

What San Francisco did: What one American city does, with limited resources and jurisdiction, is hard to compare with what an entire country does. On a federal level, the U.S. has yet to agree on a successor to what has come to be seen as its draconian war on drugs. But to the extent San Francisco’s leaders could have come together to create a comprehensive drug policy plan, they never did.

Instead, city officials mostly break down into two factions. One side, represented by the San Francisco Department of Public Health and locally funded nonprofits, has focused on harm reduction efforts. The other side, led by law enforcement agencies, wants to increase the role of the police and punishment to stop drug use and dealing.

The two sides are often at odds. For example, District Attorney Brooke Jenkins argues that the straw-and-foil distribution program isn’t supported by research and could be enabling drug use without a public health benefit. “No one has shown me the evidence,” she said. The Department of Public Health defended its work in a statement: “We want to make sure people do not die of an overdose before they have a chance to seek treatment.”

It’s a debate happening everywhere, with particular intensity in San Francisco. “To get a strategy, you need an objective,” said Nils Behnke, former chief executive of St. Anthony’s Foundation, which provides housing and treatment to drug users in the city. “That does not exist here.”