Iranian President Ahmadinejad
Iranian President Ahmadinejad (Reuters)

Iran's judiciary has barred President Mahmoud Ahmadinejad from visiting Tehran's Evin prison where his press adviser is serving a six-month sentence.

Ali Akbar Javanfekr, also head of the country's state news agency IRNA, was jailed in September for publishing an article that was considered offensive to public decency, and insulting Iranian Supreme Leader Ayatollah Ali Khamenei on his personal blog.

"As we are faced with special circumstances and the country's priorities are the economy and people's living conditions, all authorities should focus on solving key issues visiting a prison is extraneous," said chief prosecutor Gholam Hossein Mohseni Ejeie.

Ejeje said that Ahmadinejad's interest in Evin was connected to "a person affiliated to [the government] in prison", alluding to Javanfekr.

Ahmadinejad and his press aide have long been targeted by ultra-conservatives who accuse them to undermine religious principles upon which the Islamic Republic was founded.

Tensions between the president and the supreme leader have intensified following a public spat in 2011, when Khamenei, who holds ultimate power, reinstated intelligence minister Heydar Moslehi who Ahmadinejad had previously fired.

Ultra-conservative slam the presidency for mishandling the currency crisis and other economic crunch due to international sanctions against Iran's nuclear programme.

Ahmadinejad and his entourage accused the judiciary, formed by hard-line conservatives, of imprisoning people close to the president to put pressure on him.

The development came after the Khamenei representative for the Iranian Revolutionary Guard Corps (IRGC) Ali Saidi-Shahroudi said he "regrets" having supported Ahmadinejad in the past.

"I admit that I have supported Ahmadinejad in the past, but we did not have the precise knowledge of what is going on in his mind, or what he wants to do in the future," Saidi-Shahroudi told Etimad newspaper.