The legislation introduces a near-zero limit for drugs most associated with illegal use, including cocaine, cannabis, ketamine, LSD, meth, ecstasy and heroin.
The limits are not zero to allow for minor accidental exposure to such drugs.
Several drugs with medical uses will have limits based on impairment, including clonazepam, diazepam, flunitrazepam, lorazepam, methadone, morphine, oxazepam and temazepam.
Police will use mouth swabs to test drivers suspected of drug driving or who have been in an accident or stopped for a traffic offence.
Currently, it is illegal to be in charge of a motor vehicle while unfit through drugs with the penalties - a minimum 12-month driving ban, up to six months in prison and a fine of up to £5,000 - reserved to Westminster.
The new drug limits, which are devolved, will remove the need to prove impairment and come into force on October 21.
The new legislation will operate alongside the existing law and carry the same penalties.
People taking medication as prescribed can claim a medical defence against the new legislation, but can still be prosecuted under the impairment offence if the prescription indicates that they should not drive while taking the medication.
Police Scotland head of road policing, Chief Superintendent Stewart Carle, said: "With our partners, we are committed to reducing road casualties and deplore the devastating consequences of drug driving on victims, their families and communities.
"This new legislation gives the police powers to detect, at the roadside, those selfish motorists who risk the lives of others and themselves by driving after taking illegal substances.
"Over and above our priorities for road safety, there will be wider benefits for improved public safety as these powers and new equipment will help us disrupt illegal drugs supply by dealers, and organised crime groups by deterring and detecting drug drivers."
Justice Secretary Humza Yousaf praised the work undertaken to prepare for the new legislation.
He said: "Driving a vehicle while under the influence of drugs is simply not acceptable. The consequences of causing a collision while under the influence can be devastating.
"I am grateful to Police Scotland, the Scottish Police Authority, and the Crown Office and Procurator Fiscal Service for their hard work to prepare for the new laws coming into force.
"Alongside our stringent drink driving limits, these new curbs will ensure Scotland's law enforcement agencies have the most robust powers in the UK to tackle impaired and unsafe driving in order to keep people safe."