Boris Johnson has blamed a “mutant algorithm” for the A-level results fiasco before sacking the most senior official at the Department for Education.

Jonathan Slater will stand down as permanent secretary at the department on 1 September, following the furore over the awarding of A-level grades this month.

He is the second top official to leave their job in the wake of the debacle, after it was announced on Tuesday that Ofqual’s chief regulator Sally Collier would depart her position.

On a visit to a school in Coalville, Leicestershire, on Wednesday, Mr Johnson acknowledged 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 pupils.

“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.”

A mutant is an organism that is different from others of its type because of a permanent change in its genes.

Responding to the prime minister’s comments, Labour’s shadow education secretary Kate Green accused Mr Johnson of “shamelessly trying to avoid taking responsibility for the exams fiasco that his government created”.

Boris Johnson blames 'mutant algorithm' for A-level results fiasco, then sacks education chief
Students protested over the use of an algorithm to award their grades

She added: “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.

“It is this Tory government’s incompetence that is to blame for the exams fiasco.”

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.”

Despite the departures of Mr Slater and Ms Collier in the wake of the A-levels controversy, the prime minister has stood by Education Secretary Gavin Williamson.

Boris Johnson blames 'mutant algorithm' for A-level results fiasco, then sacks education chief
The prime minister has stood by Education Secretary Gavin Williamson

Mr Williamson this week refused to comment on reports he offered his resignation to Mr Johnson but had it turned down.

Announcing Mr Slater’s departure on Wednesday, a Cabinet Office statement suggested the top official was effectively sacked by Mr Johnson.

“The prime minister has concluded that there is a need for fresh official leadership at the Department for Education,” the statement read.

“Jonathan Slater has therefore agreed that he will stand down on 1 September, 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.

“A permanent successor to replace Jonathan Slater will be appointed in the coming weeks.

“The cabinet secretary would like to put on record his thanks to Jonathan for 35 years of public service, culminating in over four years as permanent secretary of the Department for Education.”

The FDA union accused the government of “scapegoating civil servants”.

“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,” they said in a statement.