A photo of Al Qaeda's new leader, Egyptian Ayman al-Zawahiri, is seen in this still image taken from a video released on September 12, 2011.

Reuters/SITE Monitoring Service via Reuters TV

LONDON When al Qaeda leader Ayman al-Zawahiri spoke in an audio message broadcast to supporters earlier this month, he had harsh words for Iran. Its true face, he said, had been unmasked by its support for Syrian President Bashar al-Assad against fighters loyal to al Qaeda.

Yet it is symptomatic of the peculiar relationship between Tehran and al Qaeda that in the same month Canadian police would accuse "al Qaeda elements in Iran" of backing a plot to derail a passenger train.

Shi'ite Muslim Iran and strict Sunni militant group al Qaeda are natural enemies on either side of the Muslim world's great sectarian divide.

Yet intelligence veterans say that Iran, in pursuing its own ends, has in the past taken advantage of al Qaeda fighters' need to shelter or pass through its territory. It is a murky relationship that has been fluid and, say some in the intelligence community, has deteriorated in recent years.

"I wouldn't even call it a marriage of convenience. It's an association of convenience," said Richard Barrett, former head of counter-terrorism for Britain's MI6 Secret Intelligence Service and later head of the U.N. Security Council's monitoring team maintaining the world body's al Qaeda and Taliban sanctions blacklists.

"It's not a strategic alliance. An al Qaeda presence may suit the Iranians because it allows them to keep an eye on them, it gives them leverage in the form of people who are akin to hostages," he added.

"There has been a lot of travel between Iraq and Pakistan and I cannot imagine the Iranians are not aware of that," he said. But it was unlikely that Iran would take the risk of actively collaborating with al Qaeda against North America: "I don't think the Iranians would take it kindly if it turned out that there had been plotting by al Qaeda on their territory."

Canadian police have said there was no sign the plot had been sponsored by the Iranian state. Iranian Foreign Ministry spokesman Ramin Mehmanparast said al Qaeda's beliefs were in no way consistent with Tehran's.

As yet, many details of the alleged plot remain unclear. However, a U.S. government source cited a network of al Qaeda fixers based in the Iranian city of Zahedan, close to the borders of both Pakistan and Afghanistan.

The source said they served as go-betweens, travel agents and financial intermediaries for al Qaeda operatives and cells operating in Pakistan and moving through the area.

Another Western source suggested that with relations deteriorating between Iran and al Qaeda over the civil war in Syria, Tehran had acted recently to stop fighters crossing through from Pakistan's Federally Administered Tribal Areas (FATA) to join Islamist militants fighting to overthrow Assad.

"Although the relationship between Iran and Al Qaeda has always been strained, this worsened after 2011 when the two sides lined up on opposite sides in the Syrian civil war," said Shashank Joshi, a researcher at the Royal United Services Institute think-tank in London.

"Syria's strongest rebel group is allied to Al Qaeda, and both have sharply criticized Iranian support for the Assad regime."

It is unclear whether the planning for the alleged Canadian plot, which Canadian police said had been in the works for some time, was carried out before Syria's war deepened the strain between Tehran and al Qaeda.

"There has been a loosening of the ties," said Barrett, noting that documents released after U.S. forces caught and killed Osama bin Laden in Pakistan in 2011 showed the al Qaeda leader saying he was not able to trust the Iranians at all.

"Since then we have Zawahri castigating Iran quite recently. So clearly something had gone wrong."

IRANIAN CONTROL FAR FROM CLEAR

If indeed the al Qaeda network was based in and around Zahedan - which lies on the main road to Pakistan and is the capital of Sistan-Baluchestan province - it is far from clear how easy it would be for Iran to control.

The region is home to a toxic mix of drug smuggling, illicit trade and gun-running by insurgents. Afghan refugees long ago crowded into poor neighborhoods on the outskirts of Zahedan, although Iran, like Pakistan, periodically tries to push them out, arguing they are a security risk.

Iranian authorities have also been battling a Sunni insurgency of their own in recent years by ethnic Baloch complaining of discrimination. The Jundollah group has claimed several attacks including a bombing that killed 42 people in 2009 - there is no sign it is linked to al Qaeda, though it is often confused with a Pakistan-based group of the same name.

At the same time, on the Pakistan side of the border, Pakistani security forces are fighting an insurgency by secular Baloch separatists, while al-Qaeda linked militants in the Sunni sectarian Lashkar-e-Jhangvi group have carried out a string of attacks against the Shi'ite population there.

PRAGMATIC APPROACH

Despite a common Western misconception that Iran, as the pre-eminent Shi'ite power, is motivated by religion, it has always been much more pragmatic in pursuing its national interest, analysts and diplomats say, allowing it to turn a blind eye to Sunni al Qaeda using its territory.

"The thing that has stymied people is that ‘al Qaeda is Sunni and the rest of the people we are talking about here are Shia. They don't mix and match.' Well, they do. And they do it whenever they want to. They just look the other way," said Nick Pratt, a retired U.S. Marines colonel and CIA officer now with the George C. Marshall European Center for Security Studies.

Before the U.S.-led invasion of Afghanistan in 2001, Iran cooperated with India and Russia against the Pakistan-backed Taliban then in power in Kabul. When al Qaeda members fled Afghanistan after the overthrow of the Taliban, it detained them under house arrest in Tehran.

"Since 9/11 a number of senior al Qaeda figures including one of Osama bin Laden's sons and senior commander and strategist Saif al Adel made their way to Iran," said Nigel Inkster, former director of operations for Britain's MI6.

"They were detained under quite strict conditions by the Iranian authorities who subsequently sought to use them as a bargaining chip with the US government in their ongoing dispute about Iran's nuclear program," added Inkster, who is now director of Transnational Threats and Political Risk at the International Institute for Strategic Studies.

Vahid Brown, a U.S.-based researcher who has written extensively on al Qaeda, said in an article on the Jihadica website earlier this year that the men who fled to Iran constituted a dissident faction within al Qaeda, which in recent years had become increasingly vocal in their criticism of bin Laden and Zawahiri.

Divided by their views on the advisability of the September 11, 2001 attacks on the United States, broadly speaking, "the pro-9/11 group, including bin Laden and Zawahiri, fled to Pakistan, while the anti-9/11 group ended up in Iran, where they were placed under house arrest by Iranian authorities," he wrote.

Iran had been willing to cooperate with the United States on Afghanistan initially, but relations soured after Tehran was denounced by then President George W. Bush as part of the "axis of evil" in 2002 and worsened further after the U.S.-led invasion of Iraq in 2003.

But Iran has been vulnerable to al Qaeda as well. After one of its diplomats was kidnapped in Pakistan some years ago it released some of the al Qaeda members it had under house arrest in exchange for his freedom, according to Pakistani media reports.

"About 18 months ago the Iranians released most if not all of those they were holding, for reasons still not entirely clear," said Inkster.

"There may well be a residual AQ presence in Iran though I would be cautious about presenting it as something very structured or hierarchic," he added.

"AQ is far from being the organization it once was and what matters more are relationships between like-minded individuals. And that may well be what we are seeing in the Canada case. There seems to be no evidence of Iranian official involvement."