Fighting continues in Libya, but only around the handful of remaining Gaddafi strongholds, in one of which the colonel himself may still be entrenched. In the rest of the country the new government seems to be successfully establishing its authority — even the BBC has finally stopped referring to its forces as “rebels”.

It could, of course, still happen but so far there is no sign of ethnic conflict breaking out, or of an insurgency against the new government, or of public hostility to the Western forces that assisted it. No sign, that is, of Libya turning into Iraq.

The Iraq comparison has been a staple of media coverage of Libya over the past six months. On the one hand, many critics of the Iraq war — whether on the left, or reformed neocons such as Andrew Sullivan — saw Libya as a new version of the same thing. On the other, many holdout defenders of the Bush administration and its supposed crusade for Middle East democracy saw Libya as their belated vindication.

And many journalists, who knew little more than that both countries had desert and were populated by Arabs, went along with the analogy, ignoring the important difference between an intervention to help belligerents who had requested it and an invasion in clear violation of international law.

So perhaps it’s time to turn the question around, and ask, not “Will Libya be like Iraq?” (and “if not, why not?”), but “Could Iraq have been like Libya?”

Imagine, for example, that intervention in Iraq had come not to suit an American political timetable, but at a time when there were already rebel forces in the field against Saddam Hussein — say in 1991, in the aftermath of the Gulf War, when the Shi’ites in the south and the Kurds in the north rose in revolt, encouraged by American propaganda, only to be subsequently abandoned.

At the time there was an extensive debate about whether the allies should have pressed on to Baghdad. George Bush snr, with his instinctive deference to dictators, chose to halt, pointing to the risks of disintegration and a long occupation — warnings that now look either prophetic or ironic, depending on one’s point of view.

But it’s possible that very little force would have been necessary. Iraq’s rebels were not asking the West to do the job for them; like Libya’s this year, what they needed was protection.

Alternatively, imagine that Saddam had remained in power until this year, only to fall victim to the same wave of revolt that has upended the rest of the region. In that case, a Libyan-style intervention might have become necessary, and might have ended with the same sort of success — at a fraction of the cost in blood and treasure of the actual Iraq war.

Indeed, without the madness of that war the revolts may have come sooner than they did. Some neocons hoped that democracy in Iraq would serve as a beacon for other Arab countries, but there’s no evidence that has happened; if anything, the dysfunctional nature of Iraq’s postwar government probably put something of a dampener on the idea of democratisation, associating it with Western imperialism rather than popular sovereignty.

Western responses to the Arab Spring have been less than ideal in many ways. Clearly many are still uncomfortable with the idea of Arab democracy, and conservative regimes such as Saudi Arabia still have powerful friends in Washington. But nothing in that response has even approximated the disregard for law and for consequences that the Americans displayed in Iraq. Lessons, for once, have been learnt.

Eight years later, Iraq is still struggling. No one much regrets the fall of Saddam, any more than there is likely to be much nostalgia for Gaddafi, but stability remains elusive. The country’s stark ethnic division has no real counterpart in Libya, but of course that’s all the more reason for letting its people sort things out themselves rather than try to impose a solution from outside.

Let’s look at Libya again in eight years. If, as I suspect, it’s in vastly better shape than Iraq today, that will be some measure of the price that was paid for bad policy.