* Iranian officials and conservative clerics condemn Paris attack
* Iran regards Sunni militants as one of biggest regional threats
* It is also seeking to strike deal with West to end sanctions
* But different message in domestic response to Charlie Hebdo
By Babak Dehghanpisheh
BEIRUT, Jan 22 (Reuters) - The deadly attack by Islamist gunmen on the offices of French newspaper Charlie Hebdo drew a somewhat unexpected response from Iranian clerics and officials: They condemned it.
Many Westerners had expected an altogether different reaction to the killings two weeks ago at the Paris weekly that had published satirical cartoons of the Prophet Mohammad.
Still fresh in their memory is the "fatwa" issued in 1989 by Iran's first religious Supreme Leader, Ayatollah Ruhollah Khomeini, ordering the death of British author Salman Rushdie for allegedly insulting the Prophet in his book "The Satanic Verses".
Some 25 years on, Iran's stance must be viewed in light of the bitter sectarian rivalry in the Middle East between Shi'ite and Sunni Muslims, political analysts say.
The Paris attack was claimed by al-Qaeda, a leading Sunni militant movement which, along with its offshoot Islamic State, Shi'ite power Iran regards as a serious threat to its allies in Syria, Iraq and Lebanon.
Iran is also treading a delicate line as it seeks to strike a deal with Western powers - including France - over its nuclear programme to put an end to the sanctions that have crippled its economy.
In a Friday prayer speech in Tehran two days after the Jan. 7 Charlie Hebdo attack, which saw gunmen kill 12 people, conservative cleric Ahmad Khatami denounced the violence.
"We strongly condemn the terrorist attack in France and believe Islam does not allow the killing of innocent people, be it in Paris, Syria, Iraq, Yemen, Pakistan or Afghanistan," said the hardliner - who last year said the fatwa to kill Rushdie was still in place.
But he also used the opportunity to criticise Western countries, which Tehran accuses of supporting some Sunni militants, such as factions of the Syrian opposition.
"U.S. dollars, UK pounds and the European Union's euros are to blame for these killings," said Khatami, according to Press TV. "These terrorists are your creation and have been nurtured by political support from you and your allies."
This was not an isolated message from an individual cleric, but came straight from the top, according to analysts.
"It was a high-level decision of the Islamic Republic. The topics of the Friday prayers are issued from a single source," said Roozbeh Mirebrahimi, an Iran analyst based in New York.
"The Friday prayer imams are sent talking points to tell them what issues to discuss."
And rather than this Iranian reaction representing any reversal, it simply reinforced Tehran's standard line of condemning Sunni "terrorism" and blaming the West for inciting it, said Karim Sadjadpour, an Iran analyst at the Carnegie Endowment for International Peace.
The Iranian foreign ministry could not be immediately reached for comment.
The hostility between the two sects of Islam stems from the regional rivalry between Iran and Saudi Arabia, whose strict brand of Wahhabism has inspired Sunni militant groups like al-Qaeda, Islamic State and the Nusra Front.
Members of Iran's Revolutionary Guard are fighting Sunni militants in both Iraq and Syria. A senior guard commander was killed in fighting in Iraq in late December and another was killed in an alleged Israeli air strike in Syria at the weekend.
The condemnation of the Paris attack was also linked to Iran's sensitive position in the ongoing nuclear negotiations to end a decade-long stand-off with the West, analysts say, something President Hassan Rouhani has staked a great deal of political capital on.
Tehran may have been unwilling to keep silent in case this was interpreted as tacit approval for the attacks.
"The Islamic Republic's current foreign policy is that they want to advance the nuclear negotiations and reach a result," said Mirebrahimi.
"They don't want to give an excuse to other countries to link them to a particular incident. After the attacks, there was widespread condemnation around the world so they showed solidarity with this."
However, inside Iran the government was sending a different message. A group of journalists who tried to hold a rally in support of the Charlie Hebdo victims the day after the attack was swiftly dispersed.
And after Charlie Hebdo published a picture of the Prophet on its cover following the attack, the climate changed markedly.
The Mardom-e Emrouz daily was shut down for printing a picture of George Clooney wearing a "Je Suis Charlie" badge on its front page. The reformist newspaper was criticised by religious hardliners for not including a condemnation of the insulting cartoons.
And several hundred Islamist protesters turned out for a demonstration in front of the French embassy earlier this week chanting "Death to France" and demanding the ejection of the French ambassador.
The mixed messages from Iranian officials and clergy could have diplomatic consequences.
"The Iranian government prevented journalists from marching in solidarity with the victims of the Charlie Hebdo massacre yet it organised flag-burning protests against the French embassy," Sadjadpour said.
"That hasn't ingratiated them to a French nuclear negotiating team that is deeply cynical about the nature of the Iranian regime."
Editing by Pravin Char