Iraq's foreign policy pressures
Over the past 10 days, Iraq has been acting somewhat adventurously.
On 2 October, Baghdad forced down an Iranian plane bound for Syria for inspection.
And on Tuesday, Prime Minister Nouri al-Maliki signed a deal to purchase $4.2bn (£2.6bn) worth of weapons from Russia.
On the surface, one act seems in defiance of Iran, and the other in defiance of the United States.
In reality, both could be part of a most unusual balancing act.
Iraq is buckling under pressure from all directions. The prospect of chaos in Syria has left the government panicking, and each of its closest allies - Tehran and Washington - is pulling Baghdad in its own direction.
Until recently, Mr Maliki seemed to possess a magical ability to keep both Washington and Tehran happy.
But recent events suggest Baghdad could eventually face the unnerving possibility of having to choose one or the other.Caught in the middle
For weeks, Western sources have accused Iran of sending planeloads of arms to Syria over Iraqi air space.
As the US pressed Iraq to inspect the planes, the government finally succumbed, forcing an Iranian cargo plane to land at Baghdad international airport, and searching it for weapons.
End Quote Toby Dodge, Reader, LSE international relations department
As the expansion of oil exports continues, the Iraqis will have lots of money. It would be sensible for Maliki to balance the source of his weaponry”
None were found, and the plane was allowed to continue its flight to Syria. Iraq publicised the event, in the hope that Washington would be appeased and the matter would be settled.
It was not. Days later, the response came from Iran, which accused Iraq of violating international aviation agreements, and expressed hope that such inspections would not be repeated.
Meanwhile, the Iraqi press were quoting government sources as saying Washington was not satisfied with random searches, and wanted all Iranian planes inspected.
As the diplomatic drama unfolded, Mr Maliki set off to Russia, where he signed the $4.2bn arms deal, making Russia the second largest supplier of weapons to Iraq.
The United States remains the first, selling Iraq all sorts of weapons as it tries to rebuild its army, including 18 F-16 fighter jets set to be delivered next year.
But with American weapons comes dependence on the US for ammunition and training.
"Maliki is aware that the Americans may eventually seek to use weapons supplies to curb his behaviour," said Toby Dodge, reader in the international relations department of the LSE.
"As the expansion of oil exports continues, the Iraqis will have lots of money. It would be sensible for Maliki to balance the source of his weaponry."Sovereignty issues
The significance of the purchase will not be lost on policy makers in Washington.
Even before the deal was sealed, the American general in charge of weapons sales to Iraq, Gen Robert Caslen, said Baghdad was looking to redress a fundamental military weakness.
"Iraq recognises they don't control their air space, and they are very sensitive to that," he told the New York Times last month.
When Turkey sends its warplanes to bomb Kurdish targets in Iraq, Iraqi officials "see it, they know it and they resent it", he added.
Turkey has been battling a Kurdish rebellion in its south-east for decades, and has been conducting cross-border raids into northern Iraq to pursue the rebels in their mountain hideouts.
On the same day Iraq inspected the Iranian plane, the government issued a decision rejecting any foreign troop presence on Iraqi soil, and any military incursions under the pretext of chasing rebels.
The decision was clearly aimed at Turkey, whose relations with the Iraqi government have been steadily deteriorating. But it did not specify how Baghdad intends to enforce it.Internal challenge
Almost a decade after the US-led invasion knocked down the Iraqi state, Baghdad is only just trying to secure its foothold.
As it looks around, it finds powers much more stable and established engaged in a battle to the death over the future of Syria. They all want Baghdad on their side.
"Iraq is back with force," said Iraqi Foreign Minister Hoshyar Zebari early this year, as Baghdad prepared to host the Arab League summit.
"Do not underestimate the Iraqi position," he said. "We do not simply follow. We have our opinion."
But amid the ferocity of the regional battle, the margin for independence keeps shrinking, and it will require great skill not to drift too far in either direction.
Mr Maliki will also have to deal with internal divisions as sharp as those in the region.
The federal government in Baghdad and the Kurdish regional government in the north have been unable to resolve fundamental differences over how much power each should have. And many of Mr Maliki's opponents accuse him of drifting towards sectarian and authoritarian rule.
Before leaving for Russia, he had to admit that any deal he signs could well be scuttled by parliament. It was a rare admission of weakness from a leader who is aware that the regional divide is reflected within Iraq itself.
Mr Maliki has been scrambling to put together a coherent response to all these challenges.
It remains to be seen whether he has managed a series of meaningless acts of political theatre, or a skilful manipulation of forces much greater than his own.