Boris Johnson faced a backlash after he sought to blame the A-level results fiasco on a "mutant algorithm" and effectively sacked the senior civil servant at the Department for Education.
The Prime Minister acknowledged the stress caused by the situation – which eventually resulted in a U-turn with A-level and GCSE grades in England awarded based on teachers' assessments rather than the algorithm.
The Department for Education announced that its permanent secretary Jonathan Slater will stand down because "the Prime Minister has concluded that there is a need for fresh official leadership".
His departure came a day after Sally Collier resigned from her role as head of exams regulator Ofqual.
Labour accused Mr Johnson of trying to avoid taking responsibility for a "shambles" caused by his Government's "incompetence".
The Prime Minister, addressing pupils at a school in Coalville, Leicestershire, acknowledged that the situation had been "stressful" for those awaiting A-level and GCSE results.
"I'm afraid your grades were almost derailed by a mutant algorithm," he told them.
"I know how stressful that must have been for pupils up and down the country.
"I'm very, very glad that it has finally been sorted out."
Mr Johnson had previously claimed that the algorithm-based grades would be "robust" and "dependable".
Shadow education secretary Kate Green said: "Boris Johnson is shamelessly trying to avoid taking responsibility for the exams fiasco that his government created.
"Responsibility for this shambles lies squarely with Downing Street and the Department for Education, who set out how they wanted the algorithm to work and were warned weeks in advance of issues, but repeatedly refused to address the problems they had created."
On Mr Slater's departure, she added: "Under this Government, civil servants have time and time again taken the fall for the incompetence and failures of ministers.
"Parents will be looking on in dismay at a government in complete chaos just a matter of days before children will return to schools.
"Leadership requires a sense of responsibility and a willingness to be held accountable, qualities this Prime Minister and his ministers utterly lack."
Kevin Courtney, joint general secretary of the National Education Union, said: "It is brazen of the Prime Minister to idly shrug away a disaster that his own Government created.
"Parents, students, teachers and heads will be horrified to see the leader of this country treat his own exams fiasco like some minor passing fad.
"The public will not easily forget the emotional rollercoaster of this year's results season. It is certain to put a long-lasting dent in the Government's reputation on education."
Education mandarin Mr Slater will stand down on September 1, in advance of the end of his tenure in spring 2021.
Susan Acland-Hood, currently interim second permanent secretary, will take over as acting permanent secretary.
Dave Penman, leader of the FDA union which represents senior public servants, said: "If it wasn't clear before, then it certainly is now – this administration will throw civil service leaders under bus without a moment's hesitation to shield ministers from any kind of accountability."
The departure of Mr Slater follows the resignation of Ms Collier from her role as Ofqual's chief regulator.
Education Secretary Gavin Williamson denied forcing her out of her post at the qualifications watchdog.
"No, this was a decision that Sally made, an incredibly dedicated and committed public servant, and in discussions with the Ofqual board, which, as you're aware, is a non-ministerial government department," he told BBC's Breakfast.
"That was a decision between them."
Mr Williamson indicated he had not considered resigning over the U-turn.
But Labour frontbencher Bill Esterson said "the buck stops" with the Education Secretary.
"First the head of the regulator Ofqual resigns over the exam fiasco, now the permanent secretary at the Department for Education," he said.
"Why is the secretary of state still in post? Two scapegoats can't save him.
"The buck stops with Williamson. Sooner or later, he has to go too."