Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

SPOKANE, Wash. — A federal judge has issued a permanent injunction blocking the Trump administration from cutting grants to Planned Parenthood that pay for a teen pregnancy prevention program in numerous states.

U.S. District Court Judge Thomas Rice of Spokane issued his ruling late Tuesday, after listening to arguments from attorneys for Planned Parenthood and the U.S. Department of Health and Human Services.

"The Court finds that HHS arbitrarily and capriciously terminated the (teen pregnancy prevention) Program," Rice wrote. "The Court determines that the public interest weighs in favor of (Planned Parenthood), as it would prevent harm to the community and prevent loss of data regarding the effectiveness of teen pregnancy prevention."

HHS Secretary Alex Azar speaks at the National Governor Association 2018 winter meeting in Washington on Feb. 24, 2018. Jose Luis Magana / AP file

The judge also denied a government motion to dismiss the case.

The decision marked the second time a federal judge found in favor of Planned Parenthood's arguments, following a ruling last week in Washington, D.C.

The lawsuit, filed in February by Planned Parenthood of Greater Washington and North Idaho, asked Rice to reverse a decision by HHS Secretary Alex Azar to cut grant funding to the program, which was supposed to continue until 2020.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The lawsuit was joined by Planned Parenthood affiliates in Alaska, Hawaii, Iowa, North Carolina, South Carolina, Louisiana, Texas and Nebraska.

The federal agency in July informed recipients of 81 teen pregnancy prevention grants that it would terminate their grant agreements two years early, despite previously seeking competitive bids for a firm to conduct the five-year study.

Jonathan Jacobson, a Department of Justice attorney, argued Tuesday that HHS had the power to end the program at any time.

"The plaintiffs are here claiming legal rights they do not have," Jacobson told Rice, according to The Spokesman-Review. "There is no legal entitlement to further funding beyond each funding year. It's the agency's discretion."

But attorneys for Planned Parenthood said the move would devastate research.

"Research doesn't happen overnight. This was set up as a five-year program," attorney Nathan Castellano said on behalf of Planned Parenthood. "Pulling the plug on these programs is extreme. It causes irreparable harm. Teens won't get the benefit of the program, and the general public won't get the benefit of the research."

Carrie Flaxman, a staff attorney for Planned Parenthood Federation of America, said she believes the move signals a shift in sex education policy under Trump.

"The Trump administration is clearly trying to push their abstinence-only agenda," said Flaxman, who is based in Washington, D.C., according to the newspaper.

The Teen Pregnancy Prevention Program has served about 1.2 million teens in 39 states and the Marshall Islands to date, the lawsuit said. That includes about 40,000 youths in Washington and Idaho.

The lawsuit also said that since the program's inception in 2010, the teen birth rate in the United States has dropped by 41 percent.

The agency cut the funding to the 81 programs a month after Trump appointed Valerie Huber as chief of staff for the Office of Assistant Secretary of Health.

After her appointment last year, Huber wrote an article decrying the lack of federal funding for abstinence education and questioned the effectiveness of teen pregnancy prevention grants.