A federal judge ruled that Harvard University’s undergraduate admissions program is constitutional, rejecting a challenge accusing the school of discrimination against Asian American applicants.

In a decision released on Tuesday, US district judge Allison Burroughs in Boston said that while Harvard’s admissions program is not perfect, “the court will not dismantle a very fine admissions program that passes constitutional muster, solely because it could do better”.

The case had pitted the Ivy League school against Students for Fair Admissions (SFFA), which opposes affirmative action policies, and whose case was backed by the Trump administration.

Supporters of the lawsuit said Harvard illegally discriminated against Asian Americans by putting a cap on the number admitted to the university, making it harder for Asian applicants to get in.

Its opponents charged that the case was not about Asian Americans at Harvard; rather, they said it was an issue that has been co-opted by conservative activists whose real goal is ending race-conscious admissions policies that give minority students a better shot at attending universities like Harvard. Supporters on both sides charged the other with racism.

Legal experts have said SFFA is likely to appeal, and the case is expected to eventually make its way up to the US supreme court, which would give its five-member conservative majority a chance to bar or more strictly limit the use of affirmative action to help minority applicants get into college.

Burroughs ruled nearly a year after holding a non-jury trial.

The SFFA group that brought the case accused Harvard of going too far by engaging in “racial balancing” that limited Asian Americans to no more than 20% of its incoming classes.

The group, founded by a longtime affirmative action opponent, Edward Blum, argued that while Asian Americans outperformed other groups on academic measures, stereotyping caused them to receive low scores on subjective “personal” ratings.

Harvard denied that charge, saying that its use of race in admissions was legal, and was not a factor in the “personal” ratings.

The US Department of Justice sided with SFFA, saying Harvard had not seriously considered race-neutral approaches to admissions. It has also investigated whether another Ivy League school, Yale University, also discriminates against Asian Americans.