LONDON — Following a national outcry, the British government on Monday made a dramatic U-turn on using an algorithm to estimate how students would have done on exams they weren't able to take because of the coronavirus lockdown.

The algorithm, which relied heavily on a school’s previous track record on exams used in university admissions, appeared to benefit students at exclusive fee-paying private schools and penalize top-performing students from disadvantaged backgrounds.

The estimates it generated threatened to lose some students the spots they had been offered at universities this fall, and that sparked outrage in a country where educational opportunities disproportionately favor those from elite backgrounds.

Prime Minister Boris Johnson defended the A-level exam results when they were released last week, saying “let’s be in no doubt about it, the exam results that we’ve got today are robust, they’re good, they’re dependable for employers.”

Gavin Williamson, the education secretary, said Saturday that there would be “no U-turn, no change” on the grading system.

But after mass protests, which included students burning their exam results in Parliament Square, Williamson struck a different tone.

“I am sorry for the distress this has caused young people and their parents but hope this announcement will now provide the certainty and reassurance they deserve,” he said Monday.

The government announced that official results would be based on whichever is higher: the algorithm approximation or teacher estimates of how their students would have done.

For about 40 percent of students in England, the algorithm produced lower A-level scores than what their teachers had predicted based on previous academic performance and mock exams.

While to some, that suggested grade inflation, the pattern of the discrepancies pointed to something else.

The downgrading impacted state schools more than fee-paying private schools — which usually have an academic selection criteria and often perform well in test results. Official statistics showed that, using the algorithm, the proportion of students who were awarded grades A and above was more than double that of state schools.

Maimuna Hassan was among the 18-year-olds shocked to find her grades downgraded.

Hassan arrived in England from Somalia at age 9 speaking no English. But she was smart and studious — the sort of student who hit the books after school and kept studying until her mom insisted she turn off the lights and go to bed.

She excelled in academics, especially sciences. As a result, she received offers to study engineering this fall at Cambridge University and Imperial College London, two of Britain’s top universities for science and engineering.

But those offers were conditional on her A-levels. On her mock exams, she earned the highest possible grade — an A* — in math and in computer science and the second highest — an A — in physics. But when she received her results last week, based on the algorithm, she got an A* in computer science, an A in math and a B in physics — not enough to get into either Cambridge or Imperial.

Hassan said the algorithm punished her for attending a high school that had previously struggled. During her time there, the Chiswick School in west London had five principals in five years.

Laura Ellener, the new principal, said in an email that her school wrote to the exam regulator in May “expressing our concerns that this statistical model was unfair on turnaround schools like ours and I am disappointed that having had months to sort this out it has turned into a complete shambles.” She welcomed the move to allow teacher-estimated scores, but she noted that it may be “too late for some students who have had university offers rejected and with courses now full.”

Hassan hopes she can still get into Cambridge, her first choice.

“Hopefully that means I got a space for uni this year or maybe the next,” she said.

For many, the algorithm debacle reflected an educational system that consistently favors elites.

About 7 percent of students in England go to private schools, some of which can top $50,000 a year, and studies show that those who attend private schools are disproportionately represented in elite jobs.

The Sutton Trust, an education charity that aims to increase social mobility, tweeted: “Reverting to teacher assessed grades will bring some long overdue clarity to the students and schools who have been unfairly affected by the adjustment process. We must ensure that this move genuinely helps social mobility and undoes some of the injustices that came to light.”