(CNN) A federal judge has ruled against the Department of Health of Human Services' decision to end a grant program aimed at curbing teen pregnancy — the fifth such ruling against the agency.

Judge Ketanji Brown Jackson of the US District Court for the District of Columbia on Friday decided in favor of the plaintiff in a class-action lawsuit against the agency.

The suit was filed in April by Healthy Futures of Texas, a nonprofit that aims to reduce teen and unplanned pregnancies, on behalf of itself and 61 other "similarly situated" organizations. All of the organizations had received five-year program grants from HHS's Teen Pregnancy Prevention Program, but were informed last summer that their funding would end two years early on June 30, 2018.

Jackson ruled that HHS's early termination of the funding was unlawful and ordered the department to proceed "as if the agency had not undertaken to shorten these grantees' federal awards." The judge had previously ruled against the termination of the funding in April in a case brought by groups in North Carolina and South Carolina.

"With this decision, our youth now have the chance for better health, educational attainment and economic opportunities that will change their lives," Evelyn Delgado, the president and CEO of Healthy Futures of Texas, said in a statement.

Read More