The court declared "illegitimate" the law, which imposed sentences of six to 20 years for trafficking in cannabis, whereas the previous law which is now back in force included sentences of between two and six years.
Leftist lawmakers and civil society representatives immediately hailed the court ruling, saying it would help ease overcrowding in Italian prisons.
The scrapping of the law could affect 10,000 detainees who are in pre-trial detention or serving time and could see a revision of their sentences and their release.
"It's a victory for everyone," said Enza Bruno Bossio, a lawmaker from the centre-left Democratic Party.
But Maurizio Gasparri, a senator from Silvio Berlusconi's centre-right Forza Italia party, said the ruling would have "devastating social consequences".