The law will suspend a long-running corruption case against Berlusconi and David Mills, a British lawyer.
Berlusconi is charged with paying Mills $600,000 in 1997 from alleged "secret funds" held by his media empire Mediaset, to withhold incriminating details of his business dealings. Both deny any wrongdoing.
Berlusconi has repeatedly accused "red" magistrates, notably in his native Milan, of conducting a witchhunt against him.
His lawyers are trying to get the Milan judge in the Mills case removed, alleging that he is politically biased.
Italian magistrates condemned the legislation as unconstitutional, saying it violated the right to a speedy trial for defendants in suspended cases.
Meanwhile, Berlusconi drew boos and catcalls on Wednesday when he slammed a "politicised" justice system in a televised address to a shopkeepers' conference.
"Politicised judges and prosecutors (are) a metastasis of democracy," Berlusconi said.
The self-made billionaire, targeted in several trials since the mid-1990s connected to his media empire, has faced charges including corruption, tax fraud, false accounting and illegally financing political parties, but he has never been definitively convicted.
Critics accuse Berlusconi of being "obsessed" with a hatred of the courts.
Berlusconi called the Italian judiciary a "cancerous growth", saying biased prosecutors had pursued him since he entered politics 14 years ago.
"(From 1994) to 2006, 789 prosecutors and magistrates took an interest in the politician Berlusconi with the aim of subverting the votes of the Italian people," he said.
|Italy's president said he feared 'a dangerous rivalry between politics and justice' [AFP]
Crossing his wrists like someone in handcuffs, Berlusconi said: "Many prosecutors would like to see me like this."
The Italian prime minister said he had spent $271 million on legal fees in a series of cases linked to his business empire, which ranges from private television to insurance services and AC Milan football club.
He described his "indignation" at being accused of using the law to promote his own interests.
Berlusconi won a third term as prime minister in May.
He promised to crack down on crime but has spent much of his time since battling with prosecutors and judges.
The clashes have undermined a truce between the government and the centre-left opposition, whose leader Walter Veltroni called Berlusconi's latest outburst "embarrassing".
Giorgio Napolitano, Italy's president, has said he fears the current climate could "rekindle a dangerous rivalry between politics and justice".
On Friday, Berlusconi's cabinet is to examine draft legislation that would grant immunity to the four highest-ranking government officials, the president, prime minister and the speakers of the two chambers of parliament.
A similar law passed by Berlusconi in 2003 was later thrown out by the country's constitutional court and proceedings against him were restarted.