The Scottish government's harassment complaints system was not drawn up to "get Alex Salmond", the country's top civil servant has told an inquiry.
Leslie Evans apologised for the government's handling of allegations against the former first minister.
But she insisted that investigating them was "the right thing to do".
MSPs are investigating the failure of the government's complaints handling process, which saw Mr Salmond awarded a £500,000 expenses payout in court.
Ms Evans - who is the permanent secretary to the Scottish government - told the Scottish Parliament inquiry she wanted to "apologise unreservedly to all concerned for this procedural failure".
Mr Salmond has previously called for the civil servant to quit, but she has been backed by the current first minister, Nicola Sturgeon.
The government launched an internal investigation into harassment complaints against Mr Salmond from two female members of staff in January 2018.
The allegations dated back to when he was serving as first minister.
Image copyright PA Media Image caption Alex Salmond walked free from court in March having been cleared of 13 charges of sexual assault and attempted rapeHowever, Mr Salmond raised a legal challenge which led to the government admitting that the investigation had been unlawful. Judge Lord Pentland said it had been "procedurally unfair" and "tainted with apparent bias" because the investigating officer assigned to the case had had prior contact with the complainers.
Mr Salmond was subsequently cleared of 13 charges of sexual assault at the High Court in Edinburgh in March.
Ms Evans accepted that "one part of our procedure should have been applied differently" during the government's investigation of the first two complaints that were made against Mr Salmond.
She said would "apologise unreservedly to all concerned for this procedural failure".
But she told the committee that "when complaints were raised, it would have been unconscionable, and a failure in our duty of care, not to investigate those complaints".
Image copyright Getty Images Image caption Ms Evans has been strongly backed by First Minister Nicola SturgeonShe went on to say that lessons had been learned from the failure, but insisted that the Scottish government "is and remains ahead of many other institutions in designing and implementing a procedure to address harassment and particularly to address historical allegations of sexual misconduct".
Ms Evans told the committee: "The Scottish government has been on a journey of cultural change since 2015 to ensure the organisation is more open, capable and responsive.
"As permanent secretary, I have led a focus on equality, inclusion and wellbeing, including addressing bullying and harassment."
Mr Salmond's defence during his criminal trial claimed that he had been the victim of a political conspiracy - something Ms Sturgeon has dismissed as "a heap of nonsense".
'Inclusive culture'
Ms Evans was asked directly if the complaints handling procedure - signed off by Ms Sturgeon in December 2017 - had been "engineered" specifically to target Mr Salmond.
The permanent secretary replied: "Absolutely not".
She confirmed that one staff member who had raised a concern about Mr Salmond's behaviour had been shown a draft of the policy, but said it was "not unusual" for someone with "lived experience" to be consulted.
"I don't believe there were any changes made as a result of that," she added.
Ms Evans was also asked about claims from civil service unions about "bullying behaviour" within the government in the past, replying that "we have got a more inclusive culture than we did have".
Image copyright Scottish Parliament Image caption Committee convener Linda Fabiani has clashed with Ms Evans over the disclosure of documentsThe Holyrood inquiry has pledged not to re-investigate any of the complaints against Mr Salmond, and will instead focus on the development of the internal government policy and the "culture of government".
The committee, led by Deputy Presiding Officer Linda Fabiani, is examining the development of the government's harassment complaints procedure, the application of that procedure to the case of Mr Salmond, and the judicial review case.
Ms Fabiani, an SNP MSP, has repeatedly clashed with the permanent secretary over documentation and written evidence being supplied by the government ahead of the hearing.
She has spoken of her "frustration and disappointment at the very limited amount of information the Scottish government has chosen to disclose" about the judicial review.
Ms Sturgeon has insisted that the complaints handling procedure she ordered to be drawn up in the wake of the Me Too movement remained "completely robust" despite the "deeply regrettable" failure in the case of her predecessor.
She has ordered an internal review of "the specific application of this one element of the procedure", and has also triggered an independent review to decide whether she broke the ministerial code in her dealings with Mr Salmond.