Sniffer dogs are to be brought in to tackle the risk of drug dealing to pupils at Douglas Ewart High School.
Sniffer dog visits to the school will be unannounced
It is part of a scheme which will see teachers and police team up to monitor the school at peak times.
Pupils will also be warned about the dangers of drug misuse as part of the operation at the Newton Stewart site.
Police stress there is no known problem at the school but said they were acting to ensure that drugs did not find their way into the area.
The school was recently the subject of a highly critical report by schools' inspectors.
Head teacher Alex Cowie said he had given a commitment the school would be a "successful and safe" place to learn.
"A key element will be to demonstrate that pupils can learn in an environment free from disruption and risk," he said.
"I want to ensure we never have a problem in Newton Stewart so I welcome the introduction of drugs dogs to assist in providing a deterrent to anyone who fancied trying to sell at or near the school."
Insp Stephen Stiff, area commander, added: "We want to ensure that both parents and pupils can have continued confidence that their school represents a safe learning environment."
He confirmed that the visit of patrol dogs would be carried out on an unannounced basis.
"There will be no set times or dates published, so my message is very clear to anyone who might have looked upon the school as a source for selling illegal substances - beware."
The action was welcomed by south of Scotland Scottish National Party MSP Alasdair Morgan.
"Clearly this is a decision which will cause parents and pupils a good deal of concern," he said.
"We need to support the move, however, given that it is clearly designed to deter drug dealers from targeting the children and ensuring that the school is a safe place to learn."