A major challenge to the use of race in college admissions was turned aside Tuesday by a federal judge in Boston who upheld affirmative action policies at Harvard University, the nation's oldest institution of higher learning.

District Judge Allison Burroughs, who was named to the bench by President Barack Obama in 2014, the same year the lawsuit was filed, ruled that Harvard did not violate federal civil rights law by using race and ethnicity as factors in the admissions process.

The affirmative action policy "serves a compelling, permissible and substantial interest, and it is necessary and narrowly tailored to achieve diversity and the academic benefits that flow from diversity," Burroughs wrote in a 130-page decision.

Her decision is almost certain to be appealed to the U.S. Court of Appeals for the First Circuit, and eventually to the Supreme Court, unless it is reversed. That process could take several more years.

Affirmative action policies have been on opponents' chopping block for decades but have been upheld by a series of Supreme Court decisions dating back to 1978. In 2003, the court opined that in 25 years, racial preferences no longer would be necessary to achieve diversity.

"As time marches on and the effects of entrenched racism and unequal opportunity remain obvious, this goal might be optimistic and may need to change," Burroughs wrote. But, she said, "The rich diversity at Harvard and other colleges and universities and the benefits that flow from that diversity will foster the tolerance, acceptance and understanding that will ultimately make race conscious admissions obsolete."

Most recently, the Supreme Court ruled 4-3 three years ago that "considerable deference is owed to a university in defining those intangible characteristics, like student body diversity, that are central to its identity and educational mission."

But that decision was written by Associate Justice Anthony Kennedy, the court's longtime swing vote, who retired last year. He was succeeded by the more conservative Associate Justice Brett Kavanaugh, giving opponents of affirmative action hope for a reversal in the future.

The case against Harvard was brought five years ago by opponents of affirmative action using the moniker Students for Fair Admissions, the brainchild of conservative legal strategist Edward Blum. In a twist, the group charged that Harvard discriminated against Asian American students in order to boost African American and Hispanic enrollment.

Blum has sought unsuccessfully over the past decade to end the use of racial preferences at the University of Texas at Austin, which the Supreme Court ultimately upheld in 2016. He also has challenged admissions policies at the University of North Carolina at Chapel Hill.

In the Harvard case, lawyers for the challengers contended that Asian American applicants were victimized by getting lower "personal ratings" than other minorities. Those ratings are intended to help create a diverse campus by focusing on characteristics other than academics, extracurricular activities, sports and legacy connections.

"Harvard asks the court to enshrine in law old and offensive stereotypes that Asian-American students are timid, quiet, shy, passive, withdrawn, one-dimensional, hard workers, perpetual foreigners, and so-called 'model minorities,'" the challengers said in court papers.

In her ruling, Burroughs said "race-conscious admissions will always penalize to some extent the groups that are not being advantaged by the process, but this is justified by the compelling interest in diversity and all the benefits that flow from a diverse college population."

Civil rights groups heralded the decision. "By upholding a policy that only views race in a positive light – never a negative one – today’s decision appropriately acknowledges that our institutions cannot be colorblind in a world full of color, nor may they be indifferent to a world full of difference,” said Kristen Clarke, president of the Lawyers' Committee for Civil Rights Under Law.

Asian American groups that opposed the lawsuit also applauded the ruling.

“As an Asian American, affirmative action helped give me a fair shot in Harvard’s application process,” said Sally Chen, who testified in support of Harvard during a three-week trial a year ago. "The court made the right decision for Asian Americans, for diversity in education, and for all of the students like me who believe race is an important part of our identity and something we deserve to be able to share."

The Trump administration's Justice Department began investigating Harvard’s admissions policies in 2017, three years after the lawsuit was begun. Last year, it filed a statement of interest in the court case on the side of the challengers.

"No American should be denied admission to school because of their race," Attorney General Jeff Sessions said at the time. "As a recipient of taxpayer dollars, Harvard has a responsibility to conduct its admissions policy without racial discrimination by using meaningful admissions criteria that meet lawful requirements."

The challengers based their case on statistical evidence, rather than bringing Asian American applicants to the stand during a three-week trial last fall. That omission was seized on by lawyers for Harvard as well as students and student groups supporting affirmative action.

"Harvard showed that it considers race as just one among many 'plus factors' in assessing candidates," the school's lawyers said. "Race matters only for candidates who would be highly competitive regardless of their race, and it matters no more than several other factors."

As one of the nation's most venerated universities, Harvard gets more than 40,000 applications annually and enrolls only about 1,650 freshmen, or 4%. The school's class of 2023 includes about 25% Asian Americans, 14% African Americans and 12% Hispanics.

Groups representing supportive students and student groups argued that eliminating race-conscious admissions "would have devastating consequences for Harvard’s campus climate."

"Student testimony establishes that the breadth and depth of racial diversity on Harvard’s campus would markedly decline, thereby exacerbating feelings of racial isolation and reducing educational benefits for all students," they said in legal papers.

Burroughs basically agreed. "Harvard has demonstrated," she said, "that no workable and available race-neutral alternatives would allow it to achieve a diverse student body while still maintaining its standards for academic excellence."