The loss could have major implications for a range of industries, including mining, transport and aviation.
The Electrical Trades Union said the decision confirmed two previous court rulings, including by the full bench of Fair Work Australia, that found the use of urine testing was "unjust and unreasonable" because it could detect drug use from days earlier, rather than more recent use that could lead to impairment at work.
Endeavour Energy launched the latest legal action in October last year, with the matter heard in the Fair Work Commission in December.
The company was attempting to vary the original decision, which required the use of oral testing, with urine-based testing.
ETU NSW deputy secretary Neville Betts said the decision, handed down late last week, highlighted the role of drug and alcohol testing in the workplace should be about identifying potential impairment, rather than disciplining staff for private actions taken in their own time.
"In recent years drug testing of employees has become increasingly common, both in the public sector and private enterprise, which is why making sure the practice is done as fairly as possible is so important," Betts said.
"While oral testing accurately identifies recent drug use, where an individual may be impaired in their abilities, urine tests unfairly monitor workers' private lives by potentially showing a positive result even where a substance may have been used many days prior, in a private capacity."
A spokeswoman for Endeavour said the company wanted to use urine-based testing because it was more accurate.