A North Carolina charter school's requirement that girls wear skirts has been struck down by a federal judge as unconstitutional.

Judge Malcolm Howard in the Eastern District of North Carolina ruled Friday that the dress code at Charter Day School in the town of Leland violates the Equal Protection Clause by discriminating against females.

"The skirt requirement causes the girls to suffer a burden the boys do not, simply because they are female," Howard ruled.

The court also rejected the school's argument that its dress code promoted "traditional values" and fostered "mutual respect" between boys and girls.

The "defendants have shown no connection between these stated goals and the requirement that girls wear skirts," the ruling said.

The decision was on a lawsuit filed in 2016 by the American Civil Liberties Union, the ACLU of North Carolina, and a law firm on behalf of three girls ages 5, 10, and 14 claiming the school's dress code led them to be colder in the winter and forced them to pay constant attention to the positioning of their legs.

"We're happy the court agrees, but it's disappointing that it took a court order to force the school to accept the simple fact that, in 2019, girls should have the choice to wear pants," said Bonnie Peltier, a parent involved in the case.

The charter school said in a written statement in 2016 that, "CDS's dress code is not discriminatory and is clearly written out such that parents and students know what is permitted."

The school has also previously defended its dress code from a legal standpoint on the basis that as a charter school it does not have to comply with the federal Title IX rule against sex discrimination in educational programs that receive federal funds.

NBC News was not immediately able to reach the school for comment after the ruling Friday.

"Yesterday's ruling vindicates our young clients, who argued that the dress code policy was both outdated and discriminatory," said Galen Sherwin, senior staff attorney at the ACLU's Women's Rights Project in a press release upon news the verdict.