* Hardliners say past cooperation with US undermined Iran
* Moderate Rohani says talks helped forestall US attacks
By Zahra Hosseinian
DUBAI, June 7 Iran's presidential election candidates clashed over foreign policy in their last televised debate on Friday, with a hardline frontrunner saying a moderate contender had undermined the country through past subservience to Western powers.
The June 14 presidential vote will be the Islamic Republic's first since the 2009 re-election of Mahmoud Ahmadinejad that led to months of unrest by backers of the losing reformist side who said his victory was rigged. Two reformist leaders have been under house arrest since 2011.
With the field narrowed to largely hardline conservative candidates, three televised debates have been held to generate more public interest in the election. But with each lasting four hours and set to a complex format devoting only short periods for questions and answers, the initiative may do the opposite.
Hassan Rohani, a moderate who was Iran's chief nuclear negotiator under reformist former president Mohammad Khatami, defended his role in foreign policy then by saying he had headed off a possible U.S. attack. He said Iran must avoid "extremism".
"During the presidency of Mr Khatami the country was saved from a crisis ... two regional countries came under attack and Iran was always in the list," he said, alluding to Afghanistan and Iraq which border Iran to the east and west respectively.
"Iran managed to distance itself from that path through wisdom and planning," said Rohani, who negotiated a suspension in Iran's uranium enrichment programme that somewhat eased tensions with Western powers, but which has been derided by conservative rivals during the campaign. The programme resumed after the hardline populist Ahmadinejad was elected in 2005.
Hardline candidate Saeed Jalili, Iran's current nuclear negotiator, lambasted Iranian foreign policy during Khatami's 1997-2005 tenure and warned that Western powers could take advantage of Iran becoming soft.
"At a time when some friends were saying .. we should avoid unnecessary confrontations with them (Western powers), what were the results?" said Jalili.
CRITICAL OF COOPERATION
"During the term of Mr Khatami and after all the cooperation on Afghanistan, they (United States) called us 'the axis of evil'. This method is wrong. If we want to pursue this method, we will see those results."
Analysts say Iran's political establishment under clerical Supreme Leader Ayatollah Ali Khamenei is intent on seeing a loyal candidate enter office and avert any repeat of the 2009 turmoil, the worst in Iran since the 1979 Islamic Revolution.
The Iranian state flatly denied doctoring the 2009 vote and said the protests were fomented by Iran's foreign enemies.
Jalili has overseen a hardening in Iran's stance in talks with six world powers seeking to restrain its nuclear programme. He is tipped as a frontrunner thanks to close ties with conservative power brokers and views similar to Khamenei's.
But Rohani, who is close to Akbar Hashemi Rafsanjani, a pragmatic president in office between 1989 and 1997, has attracted public interest in his candidacy through polished television performances and calls for moderation and diplomacy.
"All of our problems stem from this - that we didn't make an utmost effort to prevent the (nuclear) dossier from going to the (U.N.) Security Council," said Rohani, the only cleric in the presidential race.
"We need to get away from extremism. We should maintain the country's interests and national security so as to provide conditions where we create opportunities."
Iran's president generally manages domestic affairs particularly the economy and can indirectly influence foreign policy decisions. But overall state policy is the remit of Khamenei, who wields decisive powers across government and the military and security services.
In the wake of a heavy-handed security crackdown on all forms of public dissent from Islamist orthodoxy after the 2009 election, many voters are sceptical anything will change through the ballot box.
(Writing by Marcus George; Editing by Mark Heinrich)