A photograph from a jihadist news agency claims to show Isis troops and vehicles using a newly created road to cross the Syria-Iraq border. Photograph: Al-Baraka News/AFP/Getty Images

The Syrian air force jets swooped in low over the Iraqi border, dropping two bombs before soaring back to Damascus. The insurgents beneath, caught unawares, were obliterated, but the several thousand more nearby had already got what they wanted – an 800km stretch of border with Iraq that gave them an open passage between both countries.

The attack on Tuesday night was praised by Iraq's embattled leader, Nouri al-Maliki, even if he did dispute which side of the border the Syrians hit and claimed no prior knowledge of it.

In Syria, too, news travelled quickly. There though, and elsewhere, the strike in the desert was seen not as a random act but as a move choreographed with allies – some of whom were not long ago foes – to deter a common threat.

The stunning sweep made by the Isis insurgents through eastern Syria and northern Iraq has rattled the region over the past three weeks, shattering alliances and forging new ones as quickly as Iraq's northern cities have fallen. In its wake, the battle lines for the inevitable showdown with Isis are becoming ever clearer, rewriting the distinction between friend and foe, and even how wars in Iraq are fought.

Having taken Mosul and Tikrit and narrowly been beaten to Kirkuk by the Kurds, Isis is now near striking distance of some of Iraq's most strategic sites. It continues to menace the Baiji oil refinery and the Haditha dam and has encircled Iraq's largest airbase north of Taji. The advances have alarmed a region used to war but one where military threats have long been seen in conventional terms.

The Iraqi army has belatedly begun to fight back, boosted by new recruits from Shia militias. Helicopter gunships struck Tikrit on Saturday as part of what officials are describing as the start of a major offensive, though the extent of the fighting was unclear. What is almost certain is the difficulty the army faces in attempting to dislodge the militants from their newly acquired strongholds.

"A non-state actor that three years ago was a terror group that could wreak havoc in a city was one thing," said a senior Iraqi intelligence official. "But to have the same group now controlling an area from Raqqa in eastern Syria to Mosul in north-western Iraq, then down to Baquba just near Baghdad is a very different threat. It's something we've never dealt with before."

"Old enemies are now sharing intelligence," said a senior Iraqi political figure. "Even the Iranians are seeing some of the CIA work on Da'ash [a name used for Isis]."

On Thursday, the Observer witnessed a large US military cargo plane descending over Abu Ghraib and into Baghdad airport. Also watching was a convoy from the most feared militia in the land, the Iranian-backed Asa'ib ahl al-Haq, whose members sat nonchalantly under the flight path. Earlier that day, the group's leader, Major General Qassem Suleimani, the leader of the Quds Force of the Iranian Revolutionary Guards, had left Baghdad for Najaf, and then to Tehran, after overseeing plans for the defence of the capital.

Suleimani was well-known to the US officials who arrived in Baghdad's green zone earlier in the week for meetings with Maliki. For more than five years, between 2005 and 2011, he had been their chief antagonist in Iraq, with militias he directed responsible, according to Washington, for more than a quarter of all US battle casualties. This time though, the foes paid each other no heed.

The US military might that Suleimani fought so hard to counter will be needed if the battle with Isis is to be won. Iranian muscle in Baghdad will be just as important. So too will be the support of other regional states, such as Saudi Arabia and Jordan, who have no affection for Iran or Iraq and have been at odds with the White House for the last three years.

Syria looms as essential to Iraq from here on, even given the fraught recent history between Baghdad and Damascus. "They are not our friends and we know it," said an Iraqi official linked to Maliki's office. "We had big problems with them in 2009." In the summer of that year, four Iraqi government ministries were blown up with massive truck bombs and Iraq was convinced that the plots were hatched by Syrian officials.

"I went to Turkey to meet with [Syrian General] Ali Mamlouk," said the former head of the intelligence division of Iraq's interior ministry, Major General Hussein Ali Kamal. "I showed them what we had. They could not have been more guilty. Mamlouk kept repeating to me, 'I will not recognise a country that is under American occupation'."

Iraq's enmity was set aside by Syria's civil war, which was framed first by Iran, and then by Iraq, not as a populist revolt but as a fight against jihadists intent on eradicating Shias. Iran is a Shia Islamic regime, while Iraq is ruled by a Shia majority government.

Before Suleimani arrived in Baghdad, he had been based in Damascus, Iraqi and US officials say, shoring up the Syrian capital against attempts by insurgents to topple the regime of Bashar al-Assad. All the while, he had used Iraqi airspace to resupply the Syrian military with ammunition. The air route had been condemned by the US, which had demanded that Maliki force down several Iranian planes for inspection.

By late 2012, Isis operatives had become significant players in the war for northern and eastern Syria. Early the following year, the group felt strong enough to assert its supremacy over a rival jihadist organisation, Jabhat al-Nusra. Ever since, it has enforced a merciless interpretation of sharia law over Aleppo and Idlib and in the eastern third of the country, where it had used the city of Raqqa as a power base and a launching pad to push into Iraq.

All of this was while Assad turned his guns on other elements of the Syrian opposition. "We control the oilfields and all the tribal land towards Anbar," a senior Isis operative told the Observer in Antakya earlier this month. "We know they are not going to bomb our key sites. Their main enemy is the so-called moderates."

Raqqa was attacked a week after the conversation. But the main Isis base, a hospital in central Aleppo, remains unmolested by either jets or artillery. TheIsis operative said the absence of air strikes against its forces had enabled it to gather strength and numbers as it pushed towards Mosul. "Now the border is irrelevant," he said. "They are breaking down the state just as they said they would."

And herein lies the impetus for such a strange shift in alliances. "It serves no one's interests," said the senior Iraqi political figure. "Such a catastrophe would weigh everyone down for the next 20 years. Not even the Saudis want that."

The US-Iran detente has roots in attempts to solve the nuclear standoff between the Islamic republic and the west, which will reach another climax in mid-July. But Iraq's crisis is already testing the new-found connection. "There was even talk of an ops centre staffed by US and Iranians," joked one western official. "It won't go that far, but there will be an arms' length understanding."

How to stop Isis is also engaging Saudi Arabia which, despite its loathing of Maliki, is deeply uncomfortable with a jihadist push gaining momentum near its northern border. But Saudi help comes with a condition. "We will do what we have to to save our flank and play a constructive role in the region," a diplomat said. "But Maliki must go first."

Key figures

Nouri al-Maliki Fighting for his political life. Difficult to see how he could become Iraqi PM for a third term with rival sects and blocs strongly against him. Allied to Iran and Syria, civil to the US, estranged from much of the Sunni Arab world.

Barack Obama His hands-off approach to the Middle East is being sorely tested by Iraq, which is a grave test to regional stability and hence to US interests. Would rather the region solves its problems on its own terms, but has little option other than to take a stake in this crisis.

Qassem Suleimani The only non-leader on the list. Very powerful head of the Quds Force of the Iranian Revolutionary Guards. Reports directly to Ayatollah Ali Khamenei. Acts as an overlord in Damascus and Baghdad.

King Abdullah (Saudi Arabia) Loathes Maliki, and feeling is mutual. Strong supporter of the mainstream Syrian opposition. Enemy of Bashar al-Assad. Sees an Iranian hand in most of the region's flashpoints, and sees Syria and Iraq as a proxy of the Persians.

King Abdullah (Jordan) Almost powerless in the face of such regional turmoil, without support from the US and Saudi Arabia. Has tried to quarantine Jordan from the Syrian war, but has allowed the Saudis to run weapons from the south and the US to use his land to train rebel leaders.

Bashar al-Assad Holding on to Syria, with robust help from Iran and Russia, and tacit help from Maliki, who has allowed Iran to resupply his forces through Iraqi airspace. Indebted to both countries, and is going after Isis in co-operation with them.