A bill to clamp down on paedophiles grooming children on the internet has been passed by MSPs at Holyrood.
It is now an offence to 'groom' youngsters over the internet
The Protection of Children Bill will make it an offence to set up meetings with under-16s via internet chatrooms and carry a maximum 10-year sentence.
The law will allow courts to impose a new risk of sexual harm order (RSHO) to curb the activities of those suspected of being a danger to children.
RSHOs will stand even if the individual has not been convicted of an offence.
The legislation will also make it a specific offence to purchase sexual services from anyone under the age of 18 and covers activities from prostitution and pornography to lap dancing and sex chat lines.
This extends the existing laws upwards by two years from 16.
The law against indecent pictures of children was also extended to include 16 and 17-year-olds.
On passing the bill, Justice Minister Cathy Jamieson said: "The sexual abuse of children is an appalling crime.
"The physical harm that it can do to children is horrific.
"But even once the physical wounds have healed, the emotional and psychological trauma can continue for years to come.
"That's why we must do all we can to stop this happening to our children and why we must make sure the law allows for early intervention to prevent predatory sex offenders targeting our children."
The Crown would have to prove that a reasonable person would consider the intended activity to be sexual, taking into account all of the circumstances of the case, including the nature of past communications and items on the accused's person, such as contraceptives.
Detectives will be able to assume the role of the child in order to continue contact with a potential offender where they detect online grooming.
Police can apply for an RSHO against a person within six months of two incidences of inappropriate behaviour being reported to them.
Breaches of the order would be a criminal offence, punishable by up to six months in prison and/or a £5,000 fine.
Conservative deputy justice spokeswoman Margaret Mitchell backed the legislation and said: "The sexual grooming of children is a particularly heinous crime but now at least this bill will give us the measures to deal with anyone caught trying to do so.
"This sends out a strong message that grooming and paedophilia will not be accepted here and that we will do everything in our power to protect our children and catch these criminals."