Few people will, or should, feel comfortable about Tuesday's outcome of the court martial of three British soldiers who had been charged with the manslaughter of a teenage looter in Iraq. This is not because the accused were acquitted, but because the story is so ugly. Ahmed Karheem was pushed into a Basra canal. He could not swim. He drowned.

The verdict seemed just, because the soldiers acted within a context created by circumstance and accepted by their superiors. But if they were not responsible, then who was? "Wetting" wrongdoers, with varying degrees of harshness, had become a commonplace sanction in the absence of legally enforceable ones. The British army, like the US military, was utterly at a loss about how to restore order amid anarchy for which its political leadership had refused to prepare.

The historic policy of armies in such circumstances is to shoot down looters in the street. Here, instead, our soldiers adopted rough-and-ready methods. Pushing offenders into a canal is not a very grievous punishment, unless something goes horribly wrong, as it did in this case. Vastly fewer Iraqis died in the British zone than in the American one.

The accused soldiers behaved callously, but they were operating in a callous situation. Combat units are inherently unsuitable tools for imposing law and order. They are blunt instruments, not supplied with thermostats whereby the temperature of the violence that they generate can readily be adjusted to meet changing circumstances.

Young men put in possession of lethal weapons often make mistakes that cost the lives of their own comrades or civilians. No army in history has found means to prevent errors of judgment and tragic accidents on the battlefield.

As a historian of the second world war, I have recorded many episodes in 1945 Germany that seem shocking today, and far more brutal than pushing a teenager into a canal. For instance, on May 6, the 13th/18th Hussars arrested a German in civilian clothes and a Red Cross armband. He was found to have a pistol and finally admitted to being a marine - almost certainly one of the host of desperate men simply struggling to get home in the last days of the war.

The Hussars adjutant wrote in his diary: "After a certain amount of argument, we decided him a proper wrong 'un, and he was duly dispatched by firing squad in the garage."

Even the most liberal critic will probably concede that, in such a titanic conflict, some horrors were excusable. Pillage by the victors became almost universal, yet in 1944-45 disciplinary proceedings were begun against only 72 British looters, while 2,792 soldiers were charged with being improperly dressed. Relatively few cases even of rape were prosecuted. The British army allowed itself considerable indulgence towards the vanquished, albeit on a trifling scale by comparison with the Soviets.

Yet I doubt whether most readers are remotely as shocked to learn of such behaviour in Germany in 1945 as of the drowning of an Iraqi teenager in a canal in 2003. This is, of course, because few question the historic legitimacy of the British army's presence in Hitler's Reich, while many of us have the deepest doubts about what we are doing in Basra 60 years later. We find it much easier to accept misjudgments and acts of cruelty committed in the course of a mission to restore the freedom of Europe than in a war of Bush's and Blair's choice, launched under false pretences.

Yet the difficulties facing young men sent to fight in our name on foreign battlefields are the same, whether the cause is good or bad. Soldiers must respect the rule of law, and receive punishment if they do wrong. But it would be grossly unjust to transfer our indignation about disastrous policy errors made in Washington and London to the hapless squaddies at the sharp end.

Soldiers in Basra in 2003 were, in effect, invited to invent their own system of local justice, because Bush and Blair had failed to make provision for any other. This resulted in tragedies such as that which befell Karheem. I am sure there are others that we have not heard of. But, as a young soldier confronted with chaos in the streets, what would you have done amid an alien society, surrounded by enemies real and imagined, and deprived of useful guidance from higher commanders, except that it would be over the top to kill offenders?

Soldiers deployed on battlefields - and Iraq was, as it remains, a battlefield - are not equipped with batons, handcuffs, stun guns or the rules of evidence. They carry rifles, grenades and machine guns. They have trained as warriors, not policemen. Because so few modern civilians possess personal experience of war, they lack understanding of its extraordinary demands.

The first requirements of a soldier are a willingness to kill and a willingness to be killed. Neither is, thank goodness, commonplace among humanity. It is not surprising that armies are generally more skilful in generating a lot of force, for instance to crush Saddam's army, than in fine-tuning a little bit of force to combat insurgency.

The British army has always flattered itself that it conducts so-called low-intensity operations more humanely than its US counterpart. This is partially but not wholly true. British soldiers in Cyprus, Kenya and elsewhere did ruthless - even appalling - things in the course of conducting anti-terrorist campaigns half a century ago.

The army's record in Northern Ireland was remarkable, considering the decades of provocation, strain and sudden death to which soldiers were subjected. But Bloody Sunday showed how hard it can be to restrain soldiers' killing instincts. These are sometimes indispensable to defend the national interest, yet become embarrassing and indeed shameful when they're not. A sense of perspective about Iraq remains important. Some British soldiers have behaved badly, but most do extraordinarily well in desperate circumstances. The death of Karheem was overwhelmingly the fault of those in Washington and London who launched the invasion of Iraq without responsible consideration of what should follow, and still disgracefully hold public office.

It would have been monstrous to convict three guardsmen for actions that are overwhelmingly attributable to the circumstances into which they were thrust. By contrast, if George Bush, Tony Blair, Donald Rumsfeld and Lord Goldsmith had been in the dock, a guilty verdict would have been the only proper one.