BAGHDAD, Nov 8 (Reuters) - A drone attack that targeted the Iraqi prime minister on Sunday was carried out by at least one Iran-backed militia, Iraqi security officials and militia sources said, weeks after pro-Iran groups were routed in elections they say were rigged.

But the neighbouring Islamic Republic is unlikely to have sanctioned the attack as Tehran is keen to avoid a spiral of violence on its western border, the sources and independent analysts said.

Prime Minister Mustafa al-Kadhimi escaped unhurt when three drones carrying explosives were launched at his residence in Baghdad. Several of his bodyguards were injured.

The incident whipped up tensions in Iraq, where powerful Iran-backed paramilitaries are disputing the result of a general election last month that dealt them a crushing defeat at the polls and greatly reduced their strength in parliament.

Many Iraqis fear that tension among the main Shi'ite Muslim groups that dominate government and most state institutions, and also boast paramilitary branches, could spiral into broad civil conflict if further such incidents occur.

Baghdad's streets were emptier and quieter than usual on Monday, and additional military and police checkpoints in the capital appeared intent on keeping a lid on tensions.

Iraqi officials and analysts said the attack was meant as a message from militias that they are willing to resort to violence if excluded from the formation of a government, or if their grip on large areas of the state apparatus is challenged.

"It was a clear message of, 'We can create chaos in Iraq - we have the guns, we have the means'," said Hamdi Malik, a specialist on Iraq’s Shi’ite Muslim militias at the Washington Institute.

No group has claimed responsibility for the attack. Iran-backed militia groups did not immediately comment and the Iranian government did not respond to requests for comment.

Two regional officials who spoke on condition of anonymity said Tehran had knowledge about the attack before it was carried out, but that Iranian authorities had not ordered it.

Militia sources said the commander of Iran's Revolutionary Guards overseas Quds Force travelled to Iraq on Sunday after the attack to meet paramilitary leaders and urge them to avoid any further escalation of violence.

Two Iraqi security officials, speaking to Reuters on Monday on condition of anonymity,said the Kataib Hezbollah and Asaib Ahl al-Haq groups carried out the attack in tandem.

A militia source said that Kataib Hezbollah was involved and that he could not confirm the role of Asaib.

Neither group commented for the record.