Image copyright AP Image caption Research published in 2014 suggested Scottish officers were far more likely to stop and search people that colleagues elsewhere in the UK

Police officers will only be able to stop and search people when they have "reasonable grounds" to do so under new rules published by the Scottish government.

Police officers are allowed to search people for items such as drugs, stolen goods and weapons.

But there has been controversy over "consensual searches", where people are searched without any legal basis.

If approved by parliament, the code will end consensual searches from May.

Ministers asked an advisory group of experts to draft the code following a BBC Scotland investigation which revealed that hundreds of children under the age of 12 were being subjected to consensual stop searches.

The new code states that stopping and searching members of the public is a "significant intrusion into their personal liberty and privacy".

It must therefore be done for a good reason, and be both "necessary and proportionate", it says.

This means that the officer must have a "reasonable suspicion" based on "facts, information and/or intelligence" that the person being searched is likely to be carrying an illegal item.

'Harassment or intimidation'

But officers will not be allowed to search someone based purely on their appearance - for example age, race or gender - or because they have previous convictions.

The codes states: "A stop and search will not be carried out in a manner which is abusive, discriminatory, or which amounts to harassment or intimidation."

The person being searched must understand why it is being carried out, with the officer also required to carry it out "with respect for individual needs - including religious and cultural values and beliefs."

And officers must be "fully accountable" for the searches they carry out, with all stop and searches accurately recorded, and open to scrutiny.

Image copyright Police Scotland Image caption The vast majority of consensual searches on children aged under 12 did not find anything illegal

The code also sets out specific guidelines for dealing with children and vulnerable adults, and acknowledges that that they may require additional support to help them comprehend and participate in the search process.

It says: "In taking a decision to search a child or a young person, a constable must treat the need to safeguard and promote the well-being of that child or young person as a primary consideration.

"Where a constable believes it to be more harmful to a child or young person to carry out a search than not, then the search should not proceed and other measures to safeguard them should be considered."

Human rights

It also says that officers should use "age-appropriate terms" when speaking with children and young people and avoid the use of technical or legal language, unless required to do so by law.

The Scottish government announced on 4 November 2016 that there is not enough evidence to support creating a police power to search children for alcohol at this time.

The situation will be re-assessed after the code has been in force for 12 months

A code of practice underpinning the use of stop and search is required under The Criminal Justice (Scotland) Act 2016.

Justice Secretary Michael Matheson said stop and search was a valuable tool for combating crime, but that it was important to strike a balance between protecting the public and recognising people's human rights.

'Training officers'

He said: "This new code is about finding that balance and maintaining the trust between the police and the public.

"With this new code we will ensure stop and search is carried out with the fairness, integrity, respect and accountability that we expect from our police officers in all of their duties."

Research published by Edinburgh University in 2014 showed police in Scotland were far more likely to carry out stop and searches than their colleagues in England and Wales.

The figures also suggested that young people were the most likely to be searched.

But the number of stop-and-searches has fallen dramatically since then, with 888 consensual searches and 20,665 statutory searches conducted between 1 April and 30 September last year.

This compared with 450,173 consensual searches and 192,470 statutory searches in 2013/14.

Assistant Chief Constable Mark Williams said Police Scotland had made "real progress" on the issue, and "very much welcomed" the new guidelines.

He added: "We are currently training all our officers in advance of its introduction to ensure we are fully prepared."