A federal appeals court on Wednesday ruled that the Minnesota State High School League must allow two boys to compete on their high schools’ dance teams.

Juniors Dmitri Moua and Zachary Greenwald were sidelined at Roseville and Hopkins high schools because the MSHSL’s bylaws state that the teams were for girls only. The two filed a lawsuit against the league in July saying the ban was unconstitutional, arguing that they were being discriminated against on the basis of their sex.

“We never thought this was going to end,” Greenwald, 16, said Wednesday night. “For so long, I’ve just had to sit and watch. Now I’ll finally be able to participate.”

The Pacific Legal Foundation, a California-based nonprofit specializing in civil liberty violations, took up their case pro bono.

Because federal cases can take years, they also asked for an injunction to be immediately allowed on the teams while the lawsuit progressed.

U.S. District Judge Paul Magnuson initially denied the boys’ injunction, weighing who would be harmed the most by allowing the boys to dance. He said that while the boys were harmed by the ban, the damage caused to the MSHSL would be “extensive, if not irreparable” in part because the league could fall out of Title IX compliance if they let the boys dance.

Magnuson ruled that the MSHSL was allowed to create girls-only teams, such as competitive dance.

But the 8th Circuit Court of Appeals reversed that ruling, citing the 14th Amendment requirement that no state can “deny to any person within its jurisdiction the equal protection of the laws.”

While Minnesota state statute allows the league to discriminate in limited circumstances, it can do so only when athletic activities for a sex had been previously limited. Both sides submitted data to the court that showed that girls were underrepresented an average of 1 percent in interscholastic sports from 2013 to 2017.

“The League has not shown that the underlying problem it initially sought to remedy by creating all-girl teams — the overall underrepresentation of girls in high school athletics — continues to exist,” Judge Michael Melloy wrote. “The League cannot prohibit boys from participating on girls’ teams unless it has some other exceedingly persuasive justification for doing so.”

The boys’ California-based attorney, Caleb Randall Trotter, said the teens will finally be able to perform competitively next year as seniors.

“They’ve had to miss three seasons of dance already,” Trotter said, “but today’s decision means they won’t have to miss a fourth and final season.”

The larger issue of whether banning boys from competitive dance is gender discrimination is yet to be litigated in federal district court. The MSHSL could not immediately be reached for comment.

Minnesota appears to be the only state that bars boys from competitive dance.

Greenwald began dancing in fifth grade, while Moua, whose first passion was theater, discovered dance a few years later. It was a perfect fit for his creative expression.

By sophomore year, Moua wanted to move from extracurricular dance to the competitive dance team, but he was told he couldn’t try out based on his gender.

The boys served as team managers instead, tagging along at dance meets and offering encouragement.

During winter competitions, Moua usually videotaped the girls from the sideline.

“I want to be happy for them because they put in all the work, but it’s kinda disheartening when I put in the same work and I have to see them go out and perform,” said Moua, who dreams of coaching the team after graduation.

Over the years, both teens found widespread support from their female teammates and even some school administrators, but that wasn’t enough to change the rules. Legally, their hands were tied.

On Wednesday, that all changed. The news spread like wildfire at school.

Greenwald was heading to calculus when he happened to check his cellphone between periods, startled by an all caps message from his mother: “WE WON. WE DID IT. IT’S OVER.”

Now the teens are fighting to make sure that any boy entering high school who wants to dance is permitted to — “and doesn’t have to go through this entire process with lawyers and lawsuits.”