TEHRAN (Reuters) - Irans Supreme Leader Ayatollah Ali Khamenei warned senior officials on Monday not to help Tehrans enemies after two former presidents expressed defiant opposition to the result of Junes disputed presidential poll. Clashes erupted between police and reformist protesters for the first time in weeks in Tehran on Friday after former President Akbar Hashemi Rafsanjani declared the Islamic Republic in crisis and said there were doubts about the election result. That statement was a clear challenge to the authority of Khamenei, Irans most powerful figure whose endorsement of hardline President Mahmoud Ahmadinejads landslide victory was meant to be the final word on the fairness of the June 12 poll. Reformist former president, Mohammad Khatami, on Monday weighed in, calling for a referendum on the legitimacy of the government and defeated reformist candidate Mirhossein Mousavi called for the release of hundreds arrested in widespread June street protests against the election result. Elites should know that any talk, action or analysis that helps (the enemy) is a move against the nation. We should be very careful, Khamenei said in a speech to Iranian officials in a clear reference to recent statements questioning the poll. People regard with hate anyone, in any position, who wants to move society towards insecurity, Khamenei said. There are things that should not be said. If we say them, we have moved against the nation. This is now a test for the elites and failing in this test ... means falling down. Mousavi said it was wrong to accuse those detained in the protests of being linked to plots by foreign powers. It was unclear whether he made the comment in response to Khameneis remarks. Khamenei normally mediates above the political fray, but backed Ahmadinejads victory soon after the poll while reformists cried foul and said the result was rigged. Rafsanjani, a veteran insider who heads a body that can in theory dismiss the supreme leader, is now fighting for political survival because Khamenei ignored pleas to rein in Ahmadinejad after he accused the former president of corruption. On top of the June protests, the biggest in Iran since the 1979 Islamic revolution, the public battle within Irans clerical establishment poses an unprecedented challenge to the authority of Khamenei who came to power in 1989. Reformers, aware of the rising expectations of a population mostly born since the revolution, argue the Islamic Republic must become more open and accountable to its people to survive. The only way out of the current situation is to hold a referendum, websites on Monday quoted Khatami as saying. People should be asked whether they are happy with the current situation ... If the vast majority of people are happy with the current situation, we will accept it as well. Hardliners condemned Rafsanjanis Friday sermon. One cleric said Irans government drew its legitimacy from almighty God. The election dispute has further strained ties between Iran and the West, already at odds over Tehrans nuclear programme, with Western powers criticising the crackdown. Irans government accused them of plotting the overthrow of the Islamic Republic. At least 20 people died in the violence before riot police and militiamen suppressed the daily June protests and, rights groups say, arrested hundreds of people, including senior pro-reform politicians, journalists, activists and lawyers. Defeated reformist presidential candidate Mousavi said mass arrests would not solve the dispute. Let people freely express their protests and ideas, Mousavi was quoted as saying by the reformist Mosharekat website. Our dear ones in prison have no access to lawyers and are under pressure to make confessions. Mousavi was critical about linking those detained with plots by foreign countries. Isnt it an insult to 40 million voters ... linking detainees to foreign countries?, he asked. Who believes these people, many of them prominent figures, would work with the foreigners and to endanger their countrys interests? ... They should be immediately released.