New York City on Friday announced major changes to how thousands of students are assigned to middle schools, replacing a merit-based system that critics say exacerbated segregation with a lottery that is expected to create more diversity at the most sought-after schools.

The move was driven by the coronavirus pandemic, because tests typically used for admissions were not administered last spring. Selective high schools in D.C., Boston and San Francisco have also jettisoned admissions tests for the coming academic year, citing the crisis. Although these districts could reinstitute old systems after the pandemic abates, advocates have been pressing for these changes for years, and many expect them to outlive the pandemic.

“These changes will improve justice and fairness,” New York Mayor Bill de Blasio said Friday, casting the announcement as a step toward equity. “This is clearly a beginning.”

Other communities also have looked to diversify their schools, an effort that was propelled by calls for racial justice after the killing of George Floyd in Minneapolis in May. After months of emotional debate, school officials in Fairfax County, Va., announced this week that instead of an exam, they would begin using a “holistic review” to admit students to the prestigious magnet school Thomas Jefferson High School for Science and Technology. The decision is unrelated to the coronavirus, school officials said.

It comes after years of simmering concerns over the lack of Black and Hispanic students at the school and at least eight failed attempts in the past decade to boost diversity. Since the summer, a highly contentious debate has raged, with some arguing that radical change is long overdue and others worried that ­watered-down standards would destroy what made the school exceptional.

In D.C., Schools Chancellor Lewis D. Ferebee said in an interview Friday that because of the pandemic, the school system would jettison the admissions test for School Without Walls, the city’s most selective high school. Instead, admission will be determined by grades and an interview. He called this “the safest and most equitable path forward.”

There has been less drama in D.C. than in Fairfax County, but the D.C. exam has been viewed as a barrier to diversifying the student body at Walls, which attracts few low-income students. Officials said they would see how the change affects enrollment and consider whether to reinstate the test for the following school year.

Integration advocates say diverse schools give more students access to resources and benefit all students through exposure to people of different backgrounds. As is, wealthy parents use their clout to advocate for their schools’ needs and their checkbooks to provide extras. Their children bring to their school experience the advantages of travel, summer camp and tutoring. High-poverty schools, by contrast, are left to serve a concentrated population of students with great needs.

The Supreme Court has barred school systems from using students’ race in school assignment, but in recent years, some districts have adopted socioeconomic factors as an alternative as they try to diversify schools. The Century Foundation, a research group that advocates for school integration, counts 171 school districts or charter schools that consider ­socioeconomic status of families in making school assignments, up from 100 in 2016.

New York City, home to the nation’s largest school system, has long relied on family choice in student assignment to middle and high schools, with students applying to schools they want to attend. The system is intended, in part, to retain wealthier families that might otherwise leave the city or send their children to private schools.

About 200 of the city’s middle schools — 40 percent of the total — use “screens,” or academic and other criteria such as attendance or discipline records, to determine admission. That has allowed for the most advantaged students to group together into the most selective schools, concentrating White students and increasing segregation. But for the coming academic year, those screens will be eliminated, with students ranking their choices, and assignments made by lottery for schools where demand exceeds available spots. The change affects about 80,000 fifth-graders.

“These changes will improve justice and fairness, but they’ll also make the process simpler and fairer, particularly given what we’re dealing with this year,” de Blasio said.

He pointed to District 15 in Brooklyn as a success story. Last year, this district eliminated admissions criteria for middle schools and gave disadvantaged students priority in the lottery, a system adopted after a community discussion that the city is encouraging other parts of the city to begin. In District 15, the new system resulted in high-risk students being spread much more evenly across the 11 middle schools.

For high school, New York has a citywide choice system in which students can apply to schools anywhere across five boroughs. For years, however, about 250 high schools have been allowed to give preference to students who live nearby, an arrangement that exacerbates segregation by allowing schools in wealthy neighborhoods to fill up with local students.

Under rules announced Friday, those geographic preferences will be eliminated over the next two years — a permanent change.

But high schools may continue using admissions criteria, utilizing pre-pandemic test scores and grades. And New York still will determine admission to eight specialized high schools, some of the most elite in the city, through a test — a process required by state law.

Integration advocates said New York’s changes were long overdue, having been debated for years and recommended last year by an advisory committee.

“These are obvious things. I’m glad they are being done. The fact that it’s taken a global pandemic to implement common-sense and equitable admissions policies, that’s disappointing and sad,” said Matt Gonzales, the director of the Integration and Innovation Initiative at NYU Metro Center.

Brandon St. Luce, a senior at Edward R. Murrow High School in Brooklyn, said that this is a step in the right direction but that de Blasio should have removed admissions screens for high schools, too.

“He’s more afraid of White parents, who are the minority of parents in the school system, than helping the majority of students,” said St. Luce, who is co-director of policy for a group called Teens Take Charge.

Others say fears that wealthier families will abandon the system are real.

“What we’re doing is lowering the bar for everyone,” said Yiatin Chu, co-president of Parent Leaders for Accelerated Curriculum and Education, a group that supports screening in admissions. “The mayor likes to talk about equity and excellence. To me, this is neither equity nor excellence.”

She said the change will reduce the quality of schools while forcing some children into an academic environment that is too advanced for them. Teachers at New York’s selective schools, used to dealing with well-equipped and motivated children, will not be able to handle an influx of less-prepared students, Chu said, and will wind up reducing the rigor of their classes.

In many communities, the pandemic has made it virtually impossible to use testing to determine admission.

In Boston, the School Committee heard from more than 100 parents and former students before voting to suspend the admissions test for three elite schools. Proponents pointed to the pandemic, but also to issues of systemic racism.

In San Francisco, school officials voted this fall to begin using a lottery to admit students to Lowell High School, a prestigious and academically selective public school. Lowell previously judged applicants on their grade-point average, test scores and essays.

Like selective public schools across the country, Lowell has historically enrolled low percentages of Black students. Some hailed the switch as a chance to repair decades of racial injustice and expressed a hope that the change will remain after the pandemic.

“I suspect that the board will want to have a deeper conversation about whether they want to go back to how things have been done,” said Rachel Norton, a San Francisco Unified School District board member.

But some parents said the change would ruin the school’s pristine academic reputation.

“Lowell High School is one of the gems of public education,” parents wrote in a petition arguing against the lottery system and urging school officials to explore alternatives. “We urge [school officials] to proceed carefully before making any change.”

In Northern Virginia, irate students, alumni and parents formed an action group, the Coalition for TJ, that against alterations to Thomas Jefferson’s admissions system. Some of its members sued Fairfax County Public Schools, alleging discrimination against Asian American students and seeking to reverse the changes.

They assert that the new system will place unqualified children in a too-rigorous academic environment, while depriving deserving children of spots at Thomas Jefferson.

“The Fairfax County School Board has doubled down on its illegal race-based social engineering at TJ,” the Coalition for TJ said in a statement Thursday. “We will continue our campaign of moral courage for diversity, excellence and merit at America’s No. 1 high school.”

Under the new approach, adopted by the Fairfax board Thursday, the system will first identify all eighth-graders who meet certain academic criteria, including grades and courses taken.

Qualified eighth-graders will be invited to complete a math or science problem-solving essay, as well as a “Student Portrait Sheet.” Fairfax staffers will review these, taking into account “experience factors” including whether students are low-income, have special needs or come from households that do not speak English.

Ultimately, 550 middle-schoolers will receive offers each year to attend the prestigious STEM school. In a bid to ensure geographical diversity, a certain number of seats will be allotted to every middle school in Fairfax County, to be filled by eighth-graders at that school who meet criteria.

The board also considered, but rejected, an admissions lottery.

Discontent over the demographics of the student body at Thomas Jefferson has been building for years, especially among Black and Hispanic residents of Fairfax County. But it burst into public view this summer amid the nationwide protests over the Floyd killing and systemic racism. Those demonstrations coincided with Fairfax’s publication of data for Thomas Jefferson’s Class of 2024, which revealed that fewer than 10 Black students had been admitted.

“I know this has been an emotional issue,” said Fairfax School Board Vice Chair Tamara Derenak Kaufax. “Please know that it is not our desire to destroy TJ.”

Perry Stein contributed to this report.