DUBLIN (Reuters) - Ireland was rushing emergency legislation through parliament on Tuesday to make the possession of several drugs including ecstasy illegal after a court ruled that the law controlling their use was unconstitutional.

Ireland's Court of Appeal struck down part of a near 40-year old law on Tuesday, which according to Ireland's Department of Health meant possession of drugs such as ecstasy and benzodiazepines immediately ceased to be an offense.

The case concerned the prosecution of a man for possession of a substance sold by one of Ireland's so-called 'head shops', operators that sell substances often dubbed "legal" or "herbal" highs that the government sought to crack down on in 2010.

The stimulant, methylethcathinone, was added to the list of controlled substances in 2011, a move the court deemed to be unconstitutional, therefore rendering the part of the law that controlled the use of ecstasy invalid.

The outcome of the case did not affect existing laws regarding the supply, possession or sale of older drugs such as heroin, cocaine or cannabis, the health department added.

(Reporting by Padraic Halpin; editing by Ralph Boulton)