Mahmoud Ahmadinejad
Mahmoud AhmadinejadReuters

An Iranian court on Wednesday sentenced a close ally of former president Mahmoud Ahmadinejad to six-and-a-half years in prison, The Associated Press reported.

Tehran Justice Department chief Gholamhossein Esmaili said the associate, Esfandiar Rahim Mashaei, was sentenced to five years for plotting and conspiring to commit crimes against national security, one year for propaganda against the Islamic Republic system and six months for insulting officials.

The sentencing can be appealed within 20 days.

Esmaili also said there are other cases against Mashaei in court and they will be announced after the prosecution process.

Mashaei was detained in March after he burnt a copy of a court verdict sentencing Hamid Baghaei, another Ahmadinejad ally, to 15 years for misuse of public funds when he was Ahmadinejad’s vice president.

Mashaei sought to run for president in 2013 to replace Ahmadinejad but was disqualified from running.

During Baghaei’s trial, reported AP, Ahmadinejad repeatedly appeared outside the court and criticized many officials, including the head of the judiciary, Ayatollah Sadegh Amoli Larijani.

Ahmadinejad repeatedly criticized the Judiciary chief and accused him of being an oppressor.

Several of Ahmadinejad’s allies are in jail over similar charges.

Ahmadinejad, who had sought to run against Rouhani in the last election, was barred from doing so by Iran's Guardian Council, which is in charge of vetting presidential candidates.

Earlier this year, the former president was arrested by Iranian authorities and accused of inciting anti-government protests. The arrest came after he reportedly attended a rally in which he publicly criticized the government.

Ahmadinejad is notorious for his inflammatory rhetoric, particularly over Iran's nuclear program and his hostility towards Israel.

Prior to leaving the presidency, Ahmadinejad said he prided himself the most on his denial of the Holocaust.

He remains popular among the poor sections of Iran society, who were fond of his populist policies such as distributing monthly cash handouts.