Education Secretary John Swinney has survived a no-confidence vote at Holyrood over the school results row.
The Conservatives, Labour and the Lib Dems called for his resignation after thousands of teacher estimates of grades were initially marked down.
But Mr Swinney's U-turn on the issue was enough for the Scottish Greens to back the SNP in the vote.
First Minister Nicola Sturgeon said Mr Swinney was "one of the most decent and dedicated people in Scottish politics".
The motion, tabled by Labour, was defeated by 67 votes to 58.
This year's grades were based on teacher assessments because exams were cancelled due to the coronavirus pandemic.
When the results were published last week 125,000 of those estimates were downgraded by the Scottish Qualifications Authority, which said it wanted to ensure the results were comparable with previous years.
But there were claims this system unfairly penalised pupils at schools which had historically not performed so well.
On Tuesday, after an outcry and protests by students, Mr Swinney apologised and said he would direct the SQA to reissue grades "based solely on teacher or lecturer judgement".
Leading the debate at Holyrood, Scottish Labour leader Richard Leonard said Mr Swinney "only jumped to action when his own job was on the line".
He said the education secretary had presided over a series of failures, and that that the "fiasco" over exam results "must be his last".
Scottish Conservative group leader Ruth Davidson said there had been "repeated warnings" about the exams moderation issue, saying Mr Swinney "could see the car crash coming and didn't act".
She said leadership "means taking ultimate responsibility for failings in your brief", adding: "This failure is so great it demands a resignation".
'Error of judgement'
And Scottish Lib Dem leader Willie Rennie said the education secretary had made a "massive error of judgement" and had "undermined" his department, saying: "John Swinney knows in his quieter moments that he should go."
Opposition parties needed the votes of the Greens to pass the motion, but the party had already said they would not support it.
MSP Ross Greer said he had warned for months about the "fundamentally broken nature of the assessment system", saying "it should never, ever have been put into operation" - but said among opposition parties "only the Greens were actually interested in actually fixing the problem".
Ms Sturgeon, defending Mr Swinney, said he was "probably the most honourable individual I have known in my life".
She said that when the education secretary got something wrong "he has the humility to say so" - and that he had fixed the problem while there was "no comprehensive solution in England" to a similar row over A-level results.
The Greens (who have an affinity with the SNP over independence) demanded a high price for their support - a dramatic and complete u-turn on exam results from the Scottish government.
Mr Swinney acceded to all their demands by cancelling 125,000 downgrades, allowing upgraded students to keep their awards, ordering an independent review into the debacle and promising a wider look at the best way to assess pupil performance.
That amounts to the most spectacular change of policy by any minister, in any Scottish administration, in the short history of devolution since 1999.
Throughout all of this, Mr Swinney has retained the confidence and support of the first minister, Nicola Sturgeon, who relies on him heavily.
As her chosen deputy in government, he is a close and trusted ally and one of her most experienced ministers. Not someone she would want to lose or could easily replace.