(CNN) -- A federal judge has issued a permanent injunction against Florida Gov. Rick Scott's order to test most state employees for drug use, according to a ruling filed Thursday.
But the judge didn't rule on whether the state can give urine drug tests to prospective new hires.
U.S. District Judge Ursula Ungaro for the Southern District of Florida said the drug testing of about 85,000 state employees would violate the Fourth Amendment protection against unreasonable searches and sided with a motion by the American Federation of State, County and Municipal Employees Council 79, which represents about 40,000 of the employees.
But because the union didn't address new hires in its motion, the court "does not reach the issues of whether such prospective employees can be subjected to pre-employment testing and subsequent random drug testing pursuant to the executive order," the judge said.
Scott said he will appeal the ruling.
"As I have repeatedly explained, I believe that drug testing state employees is a common-sense means of ensuring a safe, efficient and productive workforce," the governor said in a written statement.
"That is why so many private employers drug test, and why the public and Florida's taxpayers overwhelmingly support this policy. I respectfully disagree with the court's ruling," Scott said.
In the ruling, Ungaro noted the governor's argument for the "numerous public benefits that the testing policy is intended to achieve, including ensuring that the public workforce is fit for duty, increasing health and safety at the public workplace, promoting greater productivity among state employees, saving taxpayer money, reducing theft at the public workplace, and decreasing the risk to public safety that drug-impaired employees pose."
The state filed studies, surveys, reports and statistics showing the prevalence of drug use in the work place, the judge said.
But random tests of employees in the state Department of Transportation and Department of Juvenile Justice show drug use in less than 1% of cases between 2008 and 2011, Ungaro said.
At the Florida Department of Corrections, employees showed drug use in random tests also in less than 1% of cases between 2008 and 2009 and then 2.4% in 2010 and 2.5% in 2011, the judge wrote. The tests at the three agencies were conducted under the state's Drug-Free Workplace Act.
The judge said the court "searches in vain" for a compelling need for testing.
"The fundamental flaw of the (executive order) is that it infringes privacy interests in pursuit of a public interest which ... is insubstantial and largely speculative," the judge wrote. "The privacy interests infringed upon here outweigh the public interest sought. That is a fatal mix under the prevailing precedents."
CNN's Melanie Whitley contributed to this report.