The rebuke follows a widely published photo showing Ahmadinejad embracing Chavez's mother at the funeral of the late Venezuelan president in what is seen as taboo-breaking behavior in Iran.
Iranian papers on Tuesday cited clerics from the religious center of Qom who described the hug as "forbidden," inappropriate behavior and "clowning around."
Iran's strict Islamic codes prohibit physical contact between unrelated members of the opposite sex.
The clerics did not spare Ahmadinejad.
"Touching a non-mahram (a woman who is not a close relative) is forbidden under any circumstances, whether shaking hands or touching by the cheek," said one of the clerics, Mohammad Taqi Rahbar, adding that such a contact, even with "an older woman is not allowed ... and contrary to the dignity of the president of the Islamic Republic of Iran."
Ayatollah Mohammad Yazdi, Iran's former judiciary chief and a religious leader in Qom, said Ahmadinejad was "clowning around" and his hug shows he failed to "protect the dignity of his nation and his position."
The clerics were also outraged by Ahmadinejad's letter of condolence to Venezuelans and their interim leader Nicolas Maduro because the Iranian president had described Chavez as a "martyr" who will be resurrected and who will return to Earth along with Jesus Christ and Imam Mahdi, a 9th century saint revered by Shiite Muslims.
"Your knowledge of religious issues is limited and no intervention could be made in this matter," said Yazdi, addressing Ahmadinejad directly.
Iranian Vice President Mohammad Reza Mirtajeddini, a cleric who accompanied Ahmadinejad to Venezuela and stood by as the Iranian president hugged Chavez's mother at the funeral last week in Caracas had initially tried to deny the story, saying the photo was a fake.
Yazdi also scolded Mirtajeddini: "You are a cleric and you wear the clerical robe ... you should not deny what happened."
The uproar surrounding the hug has given Ahmadinejad's conservative opponents fodder to criticize him, three months ahead of the June presidential elections.
Ahmadinejad can't run in the elections due to term limits under Iran's constitution but is seeking to get a protege into the race.
For their part, Iranian reformists ridiculed Ahmadinejad for weeping at Chavez's funeral.
"I burst into laughter when I saw Ahmadinejad weeping on the arm of Chavez mother, said Abbas Abdi, activist and columnist with the independent website Aftabnews.ir.
"If he needed to cry, he should have done so for his countrymen who died" in clashes with security forces during the mass protests that followed Ahmadinejad's disputed 2009 re-election, said Abdi.
Copyright 2013 The Associated Press.