Nicola Sturgeon has been released without charge pending further investigations after being arrested by police.
Scotland's former first minister was arrested in connection with the ongoing investigation into the SNP's funding and finances at 10:09 on Sunday.
After being questioned by detectives she was released from custody at 17:24.
She has since released a statement saying "I know beyond doubt that I am innocent of any wrongdoing".
Police said a report will be sent to the Crown Office and Procurator Fiscal Service.
The force has been investigating for the past two years what happened to £660,000 of donations given to the SNP by independence activists for use in a future independence referendum campaign.
Officers had been able to question Ms Sturgeon for a maximum of 12 hours before deciding whether to charge her with a crime or release her while they carry out further inquiries.
A suspect released pending further investigations can be re-arrested at a later date.
Ms Sturgeon published a statement on Twitter shortly after police confirmed her release.
She said: "To find myself in the situation I did today when I am certain I have committed no offence is both a shock and deeply distressing.
"I know that this ongoing investigation is difficult for people, and I am grateful that so many continue to show faith in me and appreciate that I would never do anything to harm either the SNP or the country."
She went on: "Innocence is not just a presumption I am entitled to in law. I know beyond doubt that I am in fact innocent of any wrongdoing."
She thanked people for messages of support and also her family for "much-needed strength at this time".
He statement ended: "While I will take a day or two to process this latest development, I intend to be back in Parliament soon where I will continue to represent my Glasgow Southside constituents to the very best of my ability."
Ms Sturgeon was succeeded as first minister and SNP leader in March by Humza Yousaf, who is now facing calls from opposition politicians and at least one of his own MPs - Angus MacNeil - to suspend her from the party.
Ms Sturgeon had attended a pre-arranged police interview and was arrested and questioned after she arrived.
It follows the arrest of her husband, former SNP chief executive Peter Murrell, on 5 April by officers who searched the couple's home in Glasgow as part of their Operation Branchform probe.
The SNP's headquarters in Edinburgh were searched on the same day and a luxury motorhome valued at about £110,000 was also seized by police from outside the home of Mr Murrell's mother in Dunfermline.
Almost two weeks later, the party's treasurer Colin Beattie was arrested.
Both men were released pending further investigations, with Mr Beattie resigning as treasurer a short time later.
The arrest of the former first minister had been widely expected as she was one of the three signatories on the SNP's accounts alongside Mr Murrell and Mr Beattie - although there was no indication of when it was going to happen.
The Branchform investigation began after complaints were made about what happened to £666,954 that was donated to the SNP by activists for a future independence referendum campaign.
The party's accounts later accounts showed it had just under £97,000 in the bank at the end of 2019, and total net assets of about £272,000.
Last year it emerged Mr Murrell gave a loan of more than £100,000 to the SNP to help it out with a "cash flow" issue after the last election.
The SNP had repaid about half of the loan by October of that year, but still owes money to Mr Murrell - although it has not said how much.
Ms Sturgeon made a shock announcement on 15 February that she would be standing down as both SNP leader and first minister once a successor was elected, with Humza Yousaf winning the contest to replace her in March.
Ms Sturgeon said at the time that she knew "in my head and in my heart" that it was the right time to go, and has denied the timing was influenced by the ongoing police investigation.
She was Scotland's longest-serving first minister and the only woman to have held the position.