MSPs have refused consent for the UK Government's controversial "spy cops" legislation, which would allow undercover agents to break the law.
Justice Secretary Humza Yousaf said insufficient safeguards have been put in place despite "limited" improvements.
The move means Scotland will be removed from the provisions of the Covert Human Intelligence Sources (Criminal Conduct) Bill.
Critics said this could jeopardise public safety.
Mr Yousaf acknowledged it could mean Holyrood has to pass emergency legislation in future to "ensure the security of police operations".
The controversial Bill would allow undercover agents to commit crimes in the course of their work, creating a new class of permission called a Criminal Conduct Authorisation.
This could be used by a range of bodies including Police Scotland.
CCAs make specific conduct “lawful for all purposes” and protect the person doing it from any liability.
The conduct must be deemed necessary and proportionate, but there is no limit on the offence it could cover, so that criminals could not devise tests to uncover any moles.
Speaking in Holyrood, Scottish Labour MSP Neil Findlay said it would be a "human rights scandal waiting to happen" and an "affront to our democracy".
Scottish Liberal Democrat MSP Liam McArthur said the Bill places "no limits on the type of crime that can be authorised, not rape, not torture, not even murder" and includes no requirement for prior judicial approval.
But Scottish Conservative MSP Liam Kerr said the ability to carry out vital covert work "presently lacks statutory foundation".
He said a court case has been brought against the UK Government relating to covert sources, with an appeal judgement due soon.
He added: "It is possible that the court will find that the current system of covert surveillance is unlawful.
"In such an event, the UK would have no basis for undertaking covert surveillance into, for example, terrorism, cyber crime, people trafficking or drugs running.
"The UK Bill anticipates this, setting a statutory framework allowing our security services and our police to continue to protect us.
"That Bill contains provisions to ensure such practices can continue in Scotland, hence the request for legislative consent today."
Mr Kerr said if Holyrood does not consent, the UK Government will remove Scotland from the Bill's provisions.
This means that if the court ruling finds against current practices, they will have to cease in Scotland immediately, he said.
He said Holyrood would then be required to pass emergency legislation in the middle of a pandemic to ensure operations can continue.
Mr Kerr told MSPs: "This is vital legislation which provides a clear and consistent statutory basis for public authorities to keep the public safe.
"Failure to give consent risks leaving Scotland's people exposed.
"That is deeply irresponsible, and I cannot believe that any MSP would vote to countenance such a situation."
Mr Yousaf said the UK Government has not brought forward amendments to the Bill that satisfy his concerns.
He said "independent judicial scrutiny" before any activity takes place would go "a long way" towards addressing worries.
However he acknowledged the forthcoming Court of Appeal judgement may require "emergency or expedited legislation" to be passed in Scotland.
He said: "That would, of necessity, be no more than just a sticking plaster to ensure the security of police operations.
"If such a measure is required, it would only be a stopgap to allow a full assessment of the Court of Appeal judgement.
"That assessment will, in turn, inform any subsequent measures that may have to be put in place by this Government or indeed by any future Government post elections."
MSPs voted to refuse consent by 92 votes to 27, with only the Tories backing the Bill.
Scottish Labour's decision to reject it contrasts with the party's position in Westminster, where UK Labour leader Sir Keir Starmer has told MPs and peers to abstain.
Two Labour frontbenchers resigned last year after voting against the legislation.
Why are you making commenting on The Herald only available to subscribers?
It should have been a safe space for informed debate, somewhere for readers to discuss issues around the biggest stories of the day, but all too often the below the line comments on most websites have become bogged down by off-topic discussions and abuse.
heraldscotland.com is tackling this problem by allowing only subscribers to comment.
We are doing this to improve the experience for our loyal readers and we believe it will reduce the ability of trolls and troublemakers, who occasionally find their way onto our site, to abuse our journalists and readers. We also hope it will help the comments section fulfil its promise as a part of Scotland's conversation with itself.
We are lucky at The Herald. We are read by an informed, educated readership who can add their knowledge and insights to our stories.
That is invaluable.
We are making the subscriber-only change to support our valued readers, who tell us they don't want the site cluttered up with irrelevant comments, untruths and abuse.
In the past, the journalist’s job was to collect and distribute information to the audience. Technology means that readers can shape a discussion. We look forward to hearing from you on heraldscotland.com
Comments & Moderation
Readers’ comments: You are personally liable for the content of any comments you upload to this website, so please act responsibly. We do not pre-moderate or monitor readers’ comments appearing on our websites, but we do post-moderate in response to complaints we receive or otherwise when a potential problem comes to our attention. You can make a complaint by using the ‘report this post’ link . We may then apply our discretion under the user terms to amend or delete comments.
Post moderation is undertaken full-time 9am-6pm on weekdays, and on a part-time basis outwith those hours.
Read the rules hereLast Updated:
Report this comment Cancel