Prime Minister Boris Johnson has blamed a "mutant algorithm" for this summer's exam results fiasco.
"I am afraid your grades were almost derailed by a mutant algorithm and I know how stressful that must have been," Mr Johnson told pupils at a school in Leicestershire.
Replacement grades caused chaos and required changes to some results.
In the fall-out from the exam problems, the Department for Education's permanent secretary has stepped down.
The National Education Union (NEU) called Mr Johnson's comments "brazen" and accused the prime minister of trying to "idly shrug away a disaster that his own government created".
Mr Johnson had been empathising with the problems of young people during the pandemic - including the "mutant algorithm" for exam grades.
Image caption Results for this year's exams were caught up in confusion"I'm very, very glad that it has finally been sorted out," he told pupils at a secondary school in Coalville.
The prime minister said education was the "great liberator" and the biggest risk for young people was not Covid-19 - it was "continuing to be out of school".
Mr Johnson told pupils that they needed to be in school to think about ideas and questions - such as "Is Harry Potter sexist? The answer is no, by the way."
But the remarks on exam problems angered the biggest teachers' union, who saw it as evading responsibility.
Kevin Courtney, joint leader of the NEU, saying parents and teachers would be "horrified to see the leader of this country treat his own exams fiasco like some minor passing fad".
"It is certain to put a long-lasting dent in the government's reputation on education."
A statement on the departure of the Department for Education's permanent secretary, Jonathan Slater, said "the prime minister has concluded that there is a need for fresh official leadership" at the department.
The role as the department's most senior civil servant will be taken on in an interim basis by Susan Acland-Hood.
This follows the resignation of Sally Collier as head of the Ofqual exam watchdog for England.
Both departures followed the high-profile problems caused by replacement grades for A-levels, GCSEs and vocational qualifications for exams cancelled in the pandemic.
This focused on an "algorithm" which was accused of producing unfair results - which after a U-turn was replaced by teachers' estimated grades.
Geoff Barton, leader of the ASCL head teachers' union, said: "It is abundantly clear that things have not gone well at the Department for Education and Ofqual, culminating in the debacle over this year's GCSE and A-level grades.
"But it is pretty unsavoury that civil servants appear to be carrying the can while ministers remain unscathed."
Labour's shadow education secretary Kate Green said: "Parents will be looking on in dismay at a government in complete chaos just a matter of days before children will return to schools."