Iranian President Mahmoud Ahmadinejad made an unusual attack on the government's highest judicial official, signalling a new phase in deteriorating relations between top Iranian leaders as the country's economic conditions and isolation over a disputed nuclear programme worsen.

Ahmadinejad was responding to the head of Iran's powerful judiciary, Ayatollah Sadegh Larijani, who on Sunday denied the president access to Tehran's Evin prison, where Ahmadinejad's top press adviser has been held since September on charges of publishing offensive material and insulting the supreme leader Ayatollah Ali Khamenei.

A judiciary spokesman said Ahmadinejad was told that his planned visit to the imprisoned adviser, Ali Akbar Javanfekr, would be inappropriate and divert attention from Iran's economic problems, which Ahmadinejad's political rivals in the government blame more on what they call his mismanagement than on the effects of the harsh Western sanctions on Iran over the nuclear programme.

Ahmadinejad responded in a letter saying that the judiciary chief, a member of the politically powerful Larijani family, had ignored corrupt officials. That was widely understood to be a reference to the judiciary chief's oldest brother, Mohammad Javad Larijani, the head of Iran's High Council for Human Rights. According to Alef, an official Iranian news website, he has been rumoured to have benefited from improper real estate dealings.

Another Larijani sibling, Ali Larijani, the speaker of parliament and Iran's former nuclear negotiator, has been an outspoken critic of Ahmadinejad and may run for president in next June's election that will determine who replaces him.

The dispute has broken out against a backdrop of an increasing economic crisis in Iran, where the currency has plummeted in value and the country's oil and banking sectors are confronting acute problems because of the Western sanctions.

Analysts say Ahmadinejad is preparing for an increasingly public fight with his political enemies within the conservative Islamic political hierarchy, the outcome of which could decide his level of influence after his second term officially ends in July.

Ahmadinejad has been particularly angry since Javanfekr, the head of the official Islamic Republic News Agency, was arrested last month - just when Ahmadinejad was visiting the UN General Assembly and giving his annual speech.

In his letter, Ahmadinejad said the decision to punish his aide was unjust and he wanted to visit Evin prison to report to the supreme leader on conditions there and "how the nation's rights are being preserved", according to the Iranian Students' News Agency. Ahmadinejad suggested the judiciary had no legal right to stop him from visiting the prison. "I have to remind you that in the constitution, there is nothing that requires asking permission or agreement of the judiciary when it comes to exercising the president's legal duties."

This article appeared in the South China Morning Post print edition as Ahmadinejad lashes outat powerful judiciary chief