BALTIMORE (AP) — A judge has sided with Baltimore and a nonprofit over the federal government in a fight over grants to prevent teen pregnancy.

Federal Judge Catherine C. Blake wrote in a ruling Wednesday that the U.S. Department of Health and Human Services acted in an “arbitrary and capricious” manner when it moved to stop grant funding under the Teen Pregnancy Prevention Program to Baltimore City and the Baltimore-based nonprofit Healthy Teen Network. That decision would have ended their grant funding two years earlier than planned. It was originally meant to last five years.

READ MORE: Maryland Weather: Tornado Warning Issued In Allegany County

Baltimore’s funding has been used for education on sexual and reproductive health for young people, while Healthy Teen Network’s funding has gone toward an app targeted at teens. Wednesday’s ruling is the third in the past week related to cuts to Teen Pregnancy Prevention grantees. All of the rulings have favored the plaintiffs. One lawsuit is still pending. Dozens of other grant beneficiaries have also been affected by cuts.

“This ruling is a victory for the youth of Baltimore City, and it’s a victory for the use of science and evidence in education and health,” said Baltimore City Health Commissioner Dr. Leana Wen.

Healthy Teen Network contended that Health and Human Services chief of staff Valerie Huber, appointed in 2017, is a longtime opponent of the program. Huber is a former president of Ascend, which used to be known as the National Abstinence Education Association and promotes abstinence-only sex education, according to the lawsuit. Healthy Teen Network publicly criticized Huber’s appointment last year.

“Abstinence alone does not address the needs of all of our youth,” said Healthy Teen Network president Dr. Patricia Paluzzi.

Health and Human Services defended its move to cut grant funding, saying studies showed the Teen Pregnancy Prevention program wasn’t working. Congress created the program in 2010.

“Continuing the program in its current state does a disservice to the youth it serves and to the taxpayers who fund it. Communities deserve better,” a department spokesperson said in a statement.

Baltimore and Healthy Teen Network learned in July 2017 that their funding would be cut short. The plaintiffs have said they received no explanation in advance why the decision was being taken, adding previous feedback from the federal agency had been positive.

READ MORE: Near-Record Heat For Preakness Stakes Another Test For Epicenter

Blake ordered the federal agency to process applications by Baltimore and Healthy Teen Network to continue the Teen Pregnancy Prevention grant funding they have been receiving. These applications are not part of a competitive process, and they’re essentially progress reports that allow organizations to continue getting their grant awards, Paluzzi said.

The nonprofit was originally awarded $3.6 million_about $723,000 per year for five years. Healthy Teen Network’s grant funding has been used for the development and testing of an app targeted at 18- to 20-year-olds. The app is intended to promote sexual and reproductive health education in English and Spanish and builds on a similar app the organization had originally developed for 15- to 17-year-olds.

“In the first three years, we adapted it, created new material, created different things in order to make it more appropriate for the age group that we were targeting,” Paluzzi said. “When the funding notice came that we were going to lose the two years, we had to make some harsh decisions.”

As a result, they shortened the follow-up period of a study from six months to six weeks and decided not to test the app in Spanish.

Baltimore City’s grant award originally totaled about $8.7 million, about $1.7 million per year for five years. Putting a halt to funding would have meant a loss of about $3.5 million over two years, according to court documents. The money Baltimore City received as part of the grant has been used to fund comprehensive reproductive health education in local middle schools and high schools, Wen said. That education includes topics such as physiology, preventing STD transmission, and empowering teens to make the best choices for themselves.

A loss of funding would mean up to 20,000 students in Baltimore would not get this education, Wen said. And the grant money has also been used to help train teachers on these programs.

“People need to continue to be vigilant and speak up and protect what they care about,” Paluzzi said. “I hope these three wins in less than a week here give people some hope and maybe cause them to take a look at what’s going on around them and see what they might do.”

(© Copyright 2018 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)

MORE NEWS: A Tornado Watch Has Been Issued For Parts Of Maryland. What Does That Mean?

Follow @WJZ on Twitter and like WJZ-TV | CBS Baltimore on Facebook