Iranian authorities say they have detained a close ally of former hard-line President Mahmud Ahmadinejad.

Esfandiar Rahim Mashaei, a former vice president and chief of staff of Ahmadinejad, was arrested on March 17, the website of Tehran’s prosecutor said.

It said Mashaei was arrested by police officers who were acting on the orders of the judiciary.

No further details were provided.

Mashaei served as first vice president in 2009 at the start of Ahmadinejad's contested second term in office.

Mashaei’s detention comes after video uploaded on social media showed him protesting outside the British Embassy in Tehran on March 15 against the incarceration of another of Ahmadinejad's vice presidents.

The semiofficial ISNA news agency quoted Mashaei’s lawyer, Mehran Abdollapour, as saying that his client was probably arrested for having burnt a copy of a court verdict sentencing Hamid Baghai during the protest.

A court in December found Baghai guilty of embezzlement and illegal business transactions, and he began serving his 15-year prison term on March 13.

Several of Ahmadinejad's allies have been jailed over the misappropriation of public funds.

Ahmadinejad, a hard-liner who was president from 2005 to 2013, defended Mashaei in a statement, calling his arrest “a violation of the constitution... that confirms the need for fundamental reforms within the judiciary."

The ex-president has become increasingly isolated for challenging Supreme Leader Ayatollah Ali Khamenei and his powerful allies, namely the judiciary.

Ahmadinejad last year accused the judiciary of "dictatorship."

In a letter marking the celebrations of the anniversary of Iran's 1979 Islamic Revolution, Ahmadinejad said in February that the judiciary has become “the main pillar of oppression” against the Iranian people.

The letter followed reports that media activists who support Ahmadinejad had been detained. The reason for their arrests was not immediately clear.

The Guardians Council -- which vets presidential candidates -- prevented Ahmadinejad and Baghai from running in the 2017 presidential election that returned President Hassan Rohani to office for a second term.

With reporting by AFP and AP