Unifor Local 707-A had argued that such random testing would violate the worker’s rights and privacy.
LISTEN: Unifor Local 707-A president Ken Smith explains why the union is opposed to random drug-testing at Suncor
Calgary-based Suncor has said random tests are needed to bolster safety and wanted start its program this month.
In his ruling, Justice Paul Belzil says the privacy rights of employees are just as important as safety.
Belzil also says random testing would affect workers who have no drug problems or have not been involved in workplace incidents.
Suncor and the union have been battling over random drug tests since 2012 and Unifor has sought leave to appeal an earlier court ruling to the Supreme Court of Canada.