A Massachusetts woman recovering from heroin addiction sued the Federal Bureau of Prisons on Friday over its policy prohibiting methadone treatment, which she wants to continue when she starts a yearlong sentence next month.

Her suit comes four months after a federal judge ordered a county jail outside Boston to let an incoming inmate stay on methadone instead of requiring him to go through forced withdrawal, as was its policy. It adds to growing pressure on the criminal justice system to provide methadone or other evidence-based treatments to the staggering number of inmates with opioid addiction.

The plaintiff, Stephanie DiPierro of Everett, Mass., was sentenced to a year and a day in federal prison after pleading guilty last fall to theft of public funds; she had collected disability benefits and food stamps without reporting income from a job. Ms. DiPierro, now 38, became addicted to opioids as a teenager after her mother died of cancer.

Since 2005, she has gone to a clinic for daily doses of methadone, a kind of opioid that was approved decades ago to control cravings and withdrawal symptoms in people addicted to narcotic painkillers and heroin.

“Methadone gave me my life back,” Ms. DiPierro, who declined to be interviewed, wrote in a sworn statement attached to the lawsuit. Without the treatment in prison, she added, she fears that upon her release, “I will lose control of my addiction and I will relapse, overdose and die.”

[Like the Science Times page on Facebook. | Sign up for the Science Times newsletter.]

The federal prison system has estimated that about 40 percent of its roughly 180,000 inmates have a substance use disorder. But while it uses methadone to detox new inmates who are dependent on opioids, it does not allow anti-craving medications as ongoing treatment except for pregnant women, who can take methadone, according to a spokesperson.

With overdose deaths from synthetic fentanyl continuing to rise, and newly released inmates at much higher risk because they lose their opioid tolerance while incarcerated, prisons and jails around the country face increasing pressure to offer anti-craving medications. But only Rhode Island and Vermont are offering state prisoners all three medications approved by the F.D.A. to treat opioid addiction: methadone, buprenorphine and naltrexone.

At the urging of the Trump administration, the prisons bureau recently started offering naltrexone to inmates who are about to be released to halfway houses. The spokesperson said naltrexone is being offered in 23 prisons in the Northeast and will eventually be expanded, but would not say how many inmates had received naltrexone injections so far.

Many in law enforcement favor naltrexone, marketed as Vivitrol, because unlike methadone and buprenorphine, it is not an opioid itself and is taken once a month instead of daily. But there is less evidence backing its effectiveness, and some studies have found people don’t stay on it as long.

More than 250 jails in 33 states now offer Vivitrol to at least some addicted inmates, typically just before their release, according to Andy Klein, a senior scientist for Advocates for Human Potential, a company that provides training to prisons and jails with addiction treatment programs.

“It’s been practically doubling every year,” Mr. Klein said, though he added that only a few dozen jails offer buprenorphine (also known as Suboxone) or methadone.

Ms. DiPierro’s lawsuit alleges that in prohibiting medication for a diagnosed condition, the Bureau of Prisons is violating the Eighth Amendment’s ban on cruel and unusual punishment. It also accuses the prisons bureau of violating the Rehabilitation Act of 1973, which protects people with disabilities from discrimination by federal agencies.

“The Bureau of Prisons is denying her a reasonable accommodation as a result of her disability, and also discriminating between different disabilities,” said Jessie Rossman, a staff lawyer at the American Civil Liberties Union of Massachusetts, which is representing Ms. DiPierro and also represented the plaintiff in last year’s county-level case. “Inmates with chronic conditions like diabetes are allowed to continue to take their medically necessary treatment.”

Ms. Rossman said the case appeared to be the first challenge to the Bureau of Prisons policy on medication-assisted treatment, adding, “What’s now coming across loud and clear is that the standard of care to treat opioid use disorder is medication-assisted treatment, and it’s ineffective and unlawful to prevent individuals from accessing their treatment and medication for that disease.”

The prisons bureau declined to comment on the lawsuit.

Giving Ms. DiPierro naltrexone before her release would do nothing to help her withdrawal symptoms and cravings while in custody, Ms. Rossman said, and staying on methadone was safer for Ms. DiPierro regardless, because it had worked for her.

Other state chapters of the A.C.L.U. — in Maine and Washington State — have filed cases seeking methadone or buprenorphine treatment in jails.

In Rhode Island, an early evaluation of the system found that nine people recently released from prison there died of an overdose in the first six months of 2016, compared with 26 people over the same period in 2016.

Ms. DiPierro wrote that she had received a diagnosis of anxiety and bipolar disorder, and feared that going through withdrawal from methadone, even if she was tapered off it, could compel her to attempt suicide.

“I am afraid of what it will mean to lose my methadone treatment at the exact moment when I am put in the most anxiety-producing situation of my life,” she wrote. “I am afraid for my life and my safety if the Bureau of Prisons withholds medicine that I know I need.”