Pfizer, the world’s second- ­largest drug company, has agreed to a written code of conduct for the marketing of opioids that some officials hope will set a standard for manufacturers of narcotics and help curb the use of the addictive painkillers.

Though Pfizer does not sell many opioids compared with other industry leaders, its action sets it apart from companies that have been accused of fueling an epidemic of opioid misuse through aggressive marketing of their products.

Pfizer has agreed to disclose in its promotional material that narcotic painkillers carry serious risk of addiction — even when used properly — and promised not to promote opioids for unapproved, “off-label” uses such as long-term back pain. The company also will acknowledge there is no good research on opioids’ effectiveness beyond 12 weeks.

The terms of the agreement were reached with the city of Chicago, which two years ago sued five other opioid manufacturers over alleged misleading marketing of opioids. An announcement of the agreement is expected Wednesday. Pfizer has also been aiding the city’s investigation and lawsuit.

Stephen R. Patton, Chicago’s corporation counsel, called Pfizer “a company that has agreed to embrace what we think are the common-sense proscriptions that we are seeking as part of our lawsuit. We hope that this trailblazing agreement . . . will set the bar for others in this industry.”

[CDC warns doctors about over-prescribing opioid painkillers]

Pfizer released a statement saying that it is “pleased to work with the city of Chicago to help address the serious problem of prescription opioid abuse. We support efforts that encourage the safe use and appropriate prescribing of opioids.” The company said it already follows many of these rules voluntarily.

But Adriane Fugh-Berman, an associate professor of pharmacology and physiology at Georgetown University School of Medicine, and director of Pharmed Out, which advocates rational prescribing practices, said she saw limited value in the agreement.

“Maybe it’s a first step, but I think counting on pharmaceutical companies to get us out of this opioid mess is not likely to be successful,” she said.

Aggressive, sometimes fraudulent marketing of OxyContin by Purdue Pharma, one of the targets of Chicago’s lawsuit, is widely blamed for the rapid growth of painkiller use across the United States. Around the turn of the century, the company mounted an aggressive campaign, initially claiming that the long-acting formulation reduced the risk of abuse and addiction.

The company swarmed primary care physicians, who had little expertise in pain management, in their offices and at ­company-sponsored conferences, at a time when the medical profession was concerned that it was not treating pain aggressively enough. Subsequent research has shown that the effort helped achieve stunning growth in the use of the painkiller, which was developed for severe pain after surgery and end-of-life care.

In 2007, Purdue pleaded guilty to criminal charges of misleading physicians, regulators and the public about the drug’s addictive qualities.

Nearly 165,000 people have died from overdoses of prescription narcotics since the turn of the century, in what the Centers for Disease Control and Prevention has called an epidemic of opiate use. The government estimates that 2.1 million people are addicted to prescription painkillers.

In its lawsuit, Chicago contends that in 2009, about 1,100 emergency room visits were the result of opioid misuse or overdose. The city also said it paid out $12.3 million in insurance claims for painkiller prescriptions between 2008 and 2015.

This year, the federal government has redoubled its efforts to address the crisis. The CDC released new guidelines that call on doctors to sharply curtail the use of narcotic painkillers. The Food and Drug Administration required that its strongest warning on immediate-release opioids include information about misuse, abuse, addiction, overdose, death and risk of neonatal withdrawal syndrome. The House and Senate each have approved bills that address the drug crisis.

[Deaths from opoid overdoses set a record in 2014]

Patton said Chicago filed the lawsuit because it believes that opioid manufacturers have continued to use deceptive tactics in the years since Purdue Pharma pleaded guilty but are doing so more subtly, often through third parties or front groups. The agreement with Pfizer requires the company to ensure that third-party materials “fairly and accurately describe the risks and benefits of opioids.”

Other cities and states, including Santa Clara and Orange counties in California and the state of West Virginia, have also sued pharmaceutical manufacturers and distributors for stoking the opiate epidemic.

New York City-based Pfizer actively promotes only one opioid painkiller, Embeda, which it acquired when it bought King Pharmaceuticals in 2011. A spokeswoman said she had no separate total for its sales, but a first- ­quarter report for 2016 shows that it is part of an “other” category of drugs that brought in $171 million worldwide.

Purdue’s blockbuster OxyContin, by contrast, produced $3.1 billion in revenue in 2010. So many opioids are sold, however, that the drug has never made up a large share of the opioid analgesic market. Last year it accounted for just 2 percent of the market, according to the company.

Pharmaceutical and biotechnology companies adhere to voluntary standards last updated in 2009 by their trade association, the Pharmaceutical Research and Manufacturers of America.