What to make of the latest alleged assassination in Iran of a senior officer in the Revolutionary Guards just as Iran and the US move towards negotiations? Is it a last-minute attempt by Israel or the Iranian dissident group the Mojahedin-e-Khalq (MEK) to sabotage talks – or at least to show that they are still players in the decades-long struggle between the government in Tehran and its many antagonists?

The first account on an Iranian website stated that Mojtaba Ahmadi, the head of Iranian cyber warfare, had been found shot in the head outside Tehran. The Revolutionary Guards issued a statement denying that he had been assassinated, but admitted there had been a "horrific incident" which it was investigating. The killing appeared to be the latest in a string of killings, since 2007, in which five Iranians associated with the country's nuclear programme have been murdered in professional attacks. Men on motorcycles operating on the basis of good intelligence have stuck magnetically attachable bombs to their victims' cars.

The timing of Ahmadi's assassination looks suspicious, coming a few days after the Iranian President, Hassan Rouhani, addressed the General Assembly of the United Nations and later spoke to President Barack Obama by telephone. Not everybody on either side is happy: the head of the Revolutionary Guards, Mohammed Ali Jafari, even stated openly that, while he agreed with Rouhani's UN speech, "he should have turned down a telephone conversation until after the American government had shown its sincerity towards Iran".

Download the new Independent Premium app Sharing the full story, not just the headlines

Jafari may be worried that Washington believes it has Iran on the run because of the devastating impact of economic sanctions.

An obvious motive for carrying out such assassinations is to demonstrate that the enemies of the Iranian government have a long reach and can identify and kill top specialists in modern warfare, notably but not exclusively those involved in the Iranian nuclear programme. This is in keeping with the plot of so many spy movies in which a single irreplaceable scientist is targeted for assassination by the forces of good or evil. In reality, such uniquely capable scientists, even where they exist, are extremely well-guarded and seldom drive their own cars. It is unlikely that any of those killed are the Iranian equivalent of J Robert Oppenheimer, the mastermind behind America's successful effort to build an atomic bomb.

Who is doing the killings? A well-sourced and convincing investigation last year by NBC News in the US concluded that "deadly attacks on Iranian nuclear scientists are being carried out by an Iranian dissident group that is financed, trained and armed by Israel's secret service". It cites two senior Obama administration officials as confirming that the MEK is responsible for the killings but denying any US involvement.

Richard Engel and Robert Windrem of NBC quote Mohammad Javad Larijani, a senior aide to Iran's spiritual leader Ali Khamenei, as asserting that Israel's secret service, Mossad, trained MEK members. He claimed that in one case it built a replica of a nuclear scientist's house so that the killers would be familiar with it. His information largely came from the interrogation of a would-be assassin detained in Iran in 2010. Larijani said that Mossad worked through the MEK because "Israel does not have direct access to our society. [The MEK], being Iranian and being part of Iranian society, they have … a good number of places... to get into touch with people."

The MEK categorically denies any involvement with Israel but Israeli commentators have confirmed the MEK-Israeli connection.

The MEK is a strange, highly disciplined, cult-like organisation which began as a militant opponent of the Shah, inspired by an ideology that is a mixture of Marxism and Islam. After Ayatollah Khomeini came to power in 1979, the MEK fought a ferocious war against his clerical regime, basing itself in Iraq with support from Saddam Hussein during the Iran-Iraq war.

During the Kurdish uprising in 1991, the Kurds blamed the MEK for blocking their advance against Saddam's forces at a crucial moment. After the fall of Saddam, the MEK established shadowy connections with the US occupation authorities, often through American contractors who had previously worked for Washington and still had their security clearances, according to Iraqi officials. This allowed the US to deny it was working with a group designated as "terrorist" by its own State Department in 1997 (though that designation was lifted last year).

Nevertheless, the investigative journalist Seymour Hersh says that, even while it was listed as a foreign terror group, MEK members received training from the Joint Special Operations Command in Nevada. During the confrontation between Tehran and Washington over Iran's nuclear programme, the MEK was attractive to US intelligence agencies because it already had committed adherents on the ground in Iran.

The US and Iran have been conducting a covert war against each other since the fall of the Shah, though its intensity goes up and down. During the Iran-Iraq war (1980-1988), the CIA had a station in Baghdad that fed satellite surveillance photographs of Iranian frontline positions to Saddam.

The conflict escalated again during the US occupation of Iraq (although Iran had quietly welcomed the toppling of its arch enemy in Baghdad). At the same time, Iran made every effort to ensure that it, and not America, became the predominant foreign power in post-Saddam Iraq. Pin-prick attacks by the two sides were highly visible from 2003 to about 2008, but less evident during this time was a degree of co-operation, since both sides wanted to stabilise a Shia-Kurdish government. Likewise today, neither country has an interest in seeing a reinvigorated al-Qa'ida establish itself in the Sunni heartlands of western Iraq and eastern Syria.

The problem with the US-Iranian proxy war is that neither side quite controls their own proxies to the degree the other side imagines. It is all very well working through surrogates to retain deniability, but these have their own interests and may, in addition, be incompetent, corrupt or simply crazed.

The MEK is not the only player in this murky and violent world. There are others such as PJAK – the Iranian Kurdish franchise of the Turkish Kurd PKK group – which is based in the southern Qandil mountains and has its militants inside Iran. Meanwhile, in Pakistani Baluchistan, there are militant Sunni groups eager for money and support from foreign intelligence services.

Some of these groups, whatever their origin, end up as guns for hire and have so many tactical alliances they must have difficulty remembering what they are fighting for.

How feasible is a US-Iranian détente? Prospects are a lot better than they have been for a long time given that US and Iranian interests in Syria are not so diametrically opposed as they were six months ago. The Sunni offensive that seemed to carry all before it in 2011 and 2012 has stalled, at least for now. But Iran does not want to give the impression that it is caving in under sanctions and Israel will want to retain its veto over any future US-Iran deal.

So, whatever the truth about the death of Mojtaba Ahmadi, the covert war between Iran and its enemies is a long way from ending.