An independent inquiry by senior Irish lawyer James Hamilton had been examining whether the first minister misled the Scottish Parliament over what she knew and when.
His report said Ms Sturgeon had given an "incomplete narrative of events" to MSPs.
But he said this was a "genuine failure of recollection" and not deliberate.
Mr Hamilton said he was therefore of the opinion that Ms Sturgeon had not breached any of the provisions of the code.
The code sets out the standards expected of Scottish government ministers, and states that anyone who deliberately misleads Holyrood would be expected to resign.
Mr Hamilton concluded in his report, some parts of which were heavily redacted, that Ms Sturgeon did not breach the ministerial code in respect of any of the four issues he considered.
These included allegations that Ms Sturgeon had failed to record a series of meetings and telephone discussions with Mr Salmond and others in 2018.
Mr Hamilton concluded that the meetings were government business - contrary to Ms Sturgeon's claims that they were a party matter - but accepted her reasoning that "it would have been impossible to record such meetings or discussions without a risk of prejudicing the proceedings or interfering with their confidentiality".
He also looked at whether the first minister "may have attempted to influence the conduct of the investigation" into the harassment complaints made against Mr Salmond, her predecessor as first minister and SNP leader.
The lawyer said the key point was that Ms Sturgeon had not intervened, and said that had Mr Salmond really believed she had agreed to it during a meeting on 2 April 2018 then, "one might have expected him to follow it up and to press home his advantage" - but that no further contact was made for three weeks.
The third issue centred on whether Ms Sturgeon misled the Scottish Parliament in relation to the meetings in 2018.
The first minister insisted she had first learned of the complaints from Mr Salmond at her home on 2 April, but later said she had had "forgotten" about a meeting with his former chief of staff four days earlier, on 29 March.
Mr Hamilton said it was "regrettable" that Ms Sturgeon had not told MSPs about this meeting, but that he found it "difficult to think of any convincing reason" for her to deliberately conceal it.
He said she had given parliament "an incomplete narrative of events", but added: "I accept that this omission was the result of a genuine failure of recollection and was not deliberate."
The fourth ground of investigation alleged that Ms Sturgeon was in breach of her duty to comply with the law in relation to Mr Salmond's successful legal challenge against the Scottish government.
Mr Salmond has pointed to external legal advice warning that the government may be at risk of losing the case as early as October 2018, but ministers decided to fight on until January 2019 - and ultimately had to pay Mr Salmond more than £500,000 in legal costs.
Mr Salmond was later cleared of 13 charges of sexual assault against nine women after a separate High Court trial in March of last year.
Mr Hamilton said Ms Sturgeon had relied on advice from the law officers, as she was "fully entitled" to do, and said Mr Salmond "appears to be under the misapprehension that the government is under a duty to withdraw a case if advised that there is less than an evens chance of winning".
The lawyer's 61-page report concluded: "I am of the opinion that the first minister did not breach the provisions of the ministerial code in respect of any of these matters."
Ms Sturgeon welcomed the findings, and said she had "sought at every stage in this issue to act with integrity and in the public interest".
She added: "As I have previously made clear, I did not consider that I had broken the code, but these findings are official, definitive and independent adjudication of that."
Ms Sturgeon again apologised to the women who made the complaints, saying they had been let down by the government.
But she said: "I was determined at the time these complaints emerged that they should not be swept under the carpet, and that I would not intervene in the process."
The first minister also called on opposition parties to respect the outcome of Mr Hamilton's inquiry, and said she would continue to devote "all of my time and energy to leading Scotland and to helping the country through the pandemic".
James Hamilton's conclusions are undoubtedly a significant boost for the first minister and her party.
In two days, the starting gun will be fired on the Scottish election campaign.
Ms Sturgeon will go into it saying her independent advisor cleared her. Her team see it as "complete vindication".
Remember there is another report to be published tomorrow morning, by the Holyrood committee.
We know a majority of the committee believe Ms Sturgeon misled them in her evidence - so the issue of trust will no doubt continue to be part of the election campaign.
But Team Sturgeon is very happy tonight - going into an election campaign which could prove very important in determining whether there is another independence referendum.
The Scottish Conservatives plan to hold a vote of no confidence in the first minister on Tuesday afternoon.
But it looks doomed to fail after the Scottish Greens said they would not support it on the basis that "the Tories have shown that they have no interest in establishing the truth."
Conservative leader Douglas Ross said the first minister had been "given a pass" by Mr Hamilton because he had judged that her failure of recollection was not deliberate.
Mr Ross said: "I respect Mr Hamilton and his judgement but we cannot agree with that assessment. Nicola Sturgeon did not suddenly turn forgetful.
"She is not free and clear. The first minister promised to respect the decisions of both inquiry reports, not to pick and choose which one suits her and try to discredit the other.
"This report does not change the overwhelming evidence that Nicola Sturgeon misled parliament, her government badly let women down and wasted more than £500,000 of taxpayers' money."
A separate report by a cross-party committee of MSPs that has been examining the government's botched handling of the complaints against Mr Salmond is expected to be published on Tuesday morning.
Details of the report that were leaked last week said that members voted by five to four that Ms Sturgeon had misled its inquiry during a marathon evidence session earlier this month.
It is also expected to be critical of the government's handling of the complaints against Mr Salmond.
Scottish Labour leader Anas Sarwar said his party had been clear that it would not prejudge the outcome of the inquiry, and would now await the findings of the parliamentary committee.
Mr Sarwar said it was clear that the saga had deeply damaged public trust in politics at a time of national crisis, and that there were "absolutely no winners today"
He added: "At the heart of this are two women who have been badly let down by the government, and it remains the case that nobody has taken responsibility."
Scottish Liberal Democrat leader Willie Rennie said Ms Sturgeon's "errors of judgement still make resignation a live consideration".
Nicola Sturgeon could not have hoped for a better outcome from this inquiry.
She effectively placed her reputation and political future in the hands of James Hamilton and he has cleared her of acting improperly. She has no intention of resigning.
That will not stop the Conservatives trying to force her out in a vote of no confidence on Tuesday - but that's a vote the first minister is expected to win with help from the Greens.
She faces further criticism in the separate Holyrood inquiry report, also due on Tuesday - with the opposition majority on that committee deciding she misled them.
Ms Sturgeon rejects that conclusion as partisan - which is how some see the decision of SNP members of the committee not to endorse it.
The arguments will continue into the Holyrood election campaign. The ultimate verdict on he Scottish government's handling harassment complaints and its wider record will be made by Scottish voters.
Change before you have to.