Rome (CNN) -- Italy's Constitutional Court Thursday struck down key parts of a law that would protect Prime Minister Silvio Berlusconi from prosecution.

The law was designed to halt criminal proceedings against top government officials for 18 months on the grounds that they are too busy to appear in court.

But Italy's top court ruled that 18 months is too long, and that judges, not politicians, should be the ones to determine if a defendant is free to appear in court.

The law will automatically be modified to conform with the ruling when the Constitutional Court publishes its verdict.

The court heard arguments Tuesday about the legality of the "legitimate impediment" law, which would have granted top Italian government officials what amounted to immunity while they were in office.

The Berlusconi-backed law said top government officials could not be prosecuted because their official duties made it impossible for them to attend court hearings.

The law was approved in March 2010, but prosecutors in Milan challenged the constitutionality of the measure, saying it should be judges, not politicians, who determined whether someone had time to attend court.

Two separate trials against Berlusconi are pending. He's accused of bribing a witness to commit perjury in one case, and of tax fraud and other financial irregularities in another. Both trials began but were suspended when the immunity law was passed.

Berlusconi has called the charges politically motivated.

A third case against the prime minister, also related to tax fraud, is in preliminary stages.

Berlusconi has been tried on at least 17 charges since first taking office as prime minister in 1994, but remains very popular with the Italian public.

The immunity law was due to expire 18 months after it was passed, which would have been in October.