Judge Datuk Ab Karim Ab Rahman ordered Tan Teck Keong's release after finding that the prosecution had failed to establish a prima facie against the accused.
In his judgment, Ab Karim said the prosecution failed to proof that Tan was in control, and had custody and knowledge of the drugs.
On the first count, Tan, 36, was charged with trafficking in 369.9 gm of the drug Methylenedioxymethamphetamine (MDMA) at a house in Jalan Sungai Bertek, Klang near here, at 3am on Nov 16, 2017.
The charge, under Section 39B (1) of the Dangerous Drugs Act (1) 1952, provides for the death sentence upon conviction.
He was also charged with two counts of drug possession, involving 148.8 gm and 51.3 gm of Nimetazepam, respectively, on the same day and the same time and place.
The drug possession charges were filed under Section 12(2) of the Dangerous Drugs Act 1952, which carries a jail sentence of up to five years and a maximum fine of RM100,000, or both, if found guilty.
Tan was represented by lawyer Datuk Hariharan Tara Singh, while the prosecution was conducted by deputy public prosecutor Ahmad Nazneen Zulkifli.