Nicola Sturgeon faced a vote of no confidence on Tuesday, brought by the Scottish Tories, who claim she misled parliament and ignored legal advice.
But the vote fell by 65 votes to 31 with 27 abstentions.
James Hamilton, the independent advisor on the ministerial code, cleared the First Minister on Monday of a breach of the code, but a cross-party committee set up to look into the botched handling of harassment complaints against Alex Salmond voted by majority to conclude she misled parliament.
Speaking in the debate on the motion, the First Minister said had the Hamilton inquiry gone the other way, she would have quit.
“Had Mr Hamilton’s report gone the other way, I would have accepted it, had he found that I had breached the code in anything other than the most technical and immaterial of ways, I would have been standing here right now tendering my resignation,” she said.
“The integrity of the office I am so privileged to hold really does matter to me.
“The office of First Minister is more important than any temporary incumbent of it.”
The First Minister also told the Tories: “If you think you can bully me out of office, you are mistaken and you misjudge me.
“If you want to remove me as First Minister do it in an election.”
She added: “If today’s desperate political stunt proves anything, it is that you have no confidence whatsoever in your ability to do so, because you have nothing positive to offer the Scottish people.”
Scottish Tory Holyrood leader, Ruth Davidson said the First Minister had been found to have misled parliament and the “honourable” thing to do after the publication of Tuesday’s report would be to step down.
“After all that evidence-gathering and deliberation, the committee found that Nicola Sturgeon misled this parliament, nothing can erase that fact, however inconvenient it is to the First Minister and her supporters,” she said.
“And let’s remember, that by misleading this Scottish Parliament, she misled the people of Scotland too.
“No First Minister who truly wanted to live up to the ideals of this parliament should feel able to continue in post after having been judged guilty of misleading it.
“How can parliament have confidence in the words of a First Minister when those words have been found to be false?
“The honourable thing would be to resign.
“Whether the First Minister has that sense of honour is now between her and her conscience.”
Labour leader Anas Sarwar took aim at both the Scottish Government, whom he said failed the two complainants, and the Tories, whom he accused of a “futile and vain pursuit of a cheap political scalp”.
Mr Sarwar said his party would not support the motion, adding: “We cannot support a motion which is designed, not to deliver the kind of strong opposition they promised, but purely at dividing our country and our politics still further.
“A failing government on one hand; a game-playing opposition on the other.
“Our politics must be better than this.
“Our people deserve better than this.
“For the sake of the people of Scotland, coming through Covid, and with the huge challenge and task that faces us, we can’t come back to this.
“Scotland deserves a better government; and it deserves a better opposition.”
He added: “The Conservatives have shown themselves as only interested in removing Nicola Sturgeon from office, rather than the facts of this terrible series of events. They have undermined the integrity of the independent investigator.
“Yet even the most ardent SNP supporter must recognise the women who complained were let down by the Government and that half a million pounds was wasted defending the indefensible in court.”
Addressing James Hamilton’s conclusion that a claim that a complainer’s name was revealed to Mr Salmond’s former chief of staff by a member of the First Minister’s team was “credible”, Mr Rennie said: “James Hamilton believes that did happen; he says that version of events is credible.
“That is a terrible breach of confidentiality. Not only were they left to swim, but their identity was passed to a person that they were complaining about.
“What is now to happen to the person responsible?”
Scottish Greens co-leader Patrick Harvie said any MSP who had leaked the findings of the committee’s report and the testimony of complainers from a private session should not be allowed to stand in May’s Holyrood elections.
He added: “They have shown contempt for the serious issue of sexual harassment. They have shown contempt for their witnesses. They have shown contempt for the rules of this Parliament.
“And, having failed in their attempt to drag Scottish politics down to their level, they should just go.”