Taking ecstasy, ketamine, magic mushrooms and so-called head shop highs has become legal in Ireland - for one night only.
A landmark case before Dublin's Court of Appeal has struck down legislation banning the possession of more than 100 drugs and substances.
The surprise move has forced the Irish parliament to sit late into the night to rush through emergency laws to shut down the loophole.
Health Minister Leo Varadkar warned anyone tempted to take advantage of the temporary decriminalisation to think about their health.
"They all have very significant health risks that outweigh any perceived recreational benefits," he said.
A qualified doctor, Mr Varadkar said he is working to pass the emergency laws within 24 hours.
"We had no way of knowing what the court would decide today, but we prepared for this possibility," he said.
The government was forced to act after a decision by the Court of Appeal on a challenge to the Misuse of Drugs Act 1977.
The case was brought by a man prosecuted for possession of methylethcathinone in 2012. He denies criminal charges of supplying the substance and argued the regulations were unconstitutional.
The substance also known as 4-mec or snow blow is one of around 100 brought under a blanket ban in Ireland four years ago, which forced head shops around the country out of business overnight.
The three-judge court unanimously agreed a regulation making the possession of methylethcathinone illegal was invalid, as it was unconstitutional.
Because of the way the laws are drawn up, the ruling had the knock-on effect of temporarily legalising the possession of other drugs in the same category.
The government is considering an appeal on the ruling.
It has also warned that sale and supply of the affected drugs remains an offence.
The outcome of the case does not affect existing laws on other traditional drugs like heroin, cocaine or cannabis.
Dozens of drugs-related convictions will be open to challenge after the 30-page ruling was handed down by the court, it is expected.
Mr Varadkar said emergency legislation, expected to be enacted by tomorrow, will re-instate "the status quo" and re-control all drugs that were controlled before the judgment.
In a statement, the Department of Health said there was always a degree of uncertainty about the outcome of court cases.
"The outcome of this case does not affect existing laws regarding the supply, possession or sale of older drugs such as heroin, cocaine or cannabis," it added.
"It does affect the possession of certain newer psychoactive substances which have been added to the Misuse of Drugs Act 1977 by successive governments.
"However, we are advised that sale and supply of psychoactive substances remains an offence under existing legislation."
Because of previous challenges to the laws, the government had prepared emergency legislation.
"It is now important from both a public health and criminal justice perspective that the legislation be enacted as soon as possible," a department spokesman added.