Ahmadinejad attacked the judiciary and its leader, Sadegh Larijani, in a video interview published on Thursday, for prosecuting his allies. He said that due to the poor performance of the judiciary and its neglect of justice, “the whole country is in danger.” Several allies of the former president are either convicted or facing pending trials.

One of his deputies, Mohammad Reza Rahimi, is currently serving a 5-year prison sentence due to conviction over corruption.

Last week the head of president’s office under Ahmadinejad, Esfandiar Rahim Mashaei, was officially charged over insulting the supreme leader, propaganda against the regime, illegal usage of government assets, insulting high ranking state officials and spreading lies.

His other deputy, Hamid Baghaei, is currently facing several legal problems. Ahmadinejad called the charges against Baghaei “fabricated”. He accused the judiciary of corruption, tyranny and dictatorship.

Baghaei’s defense strategy appears to be to also attack the judiciary. “I do not have 63 accounts, my daughter is not a spy, and I have not violated any laws in this country,” Baghaei said in a speech outside the courthouse after the second session of his trial last month.

This was a reference accusations against Sadegh Larijani, the head of the judiciary. Baghaei’s statements resulted in his being charged with defamation of high-ranking officials.

Larijani is reported to have transferred millions of dollars of his institution’s income into his private accounts. Unconfirmed reports also allege that his daughter has been charged with espionage for British embassy in Tehran. However, the government and judiciary denied both allegations.

Critical of the fact that prosecutors and prisons in Iran are under the control of the judiciary, Ahmadinejad also said that the judiciary has gave supervision of some prison wards to the intelligence service and the revolutionary guards — which is a clear violation of the law. He referred to the death of the blogger, Sattar Beheshti, 35, in Evin prison in 2012. He called it a result of having security and intelligence organs run the prisons. He insisted that this was wrong and that the judiciary was responsible for it.

Beheshti had criticized the Iranian regime and its leader Ayatollah Khamenei for human rights violations and supporting the Lebanon’s Hezbollah in his weblog. Beheshti died in custody a few days after his arrest.

Ahmadinejad said, “God may help the 17 million others who have a legal case in the judiciary.”