International law regulates the use of military force by states and the conduct of hostilities.
As in virtually every modern conflict, there is intense debate on the legality of the actions of the two sides involved here - Israel and Hamas.
Israel argues that its Operation Pillar of Defence is justified under the right of self-defence. This position has in principle been supported by various countries, including the US and EU member states.
Enshrined in Article 51 of the UN Charter, the right of self-defence is accepted as a fundamental principle of international law. While aspects of this principle are disputed, it is universally agreed that a state can defend itself against an armed attack.
There is some debate as to the intensity that an armed attack should reach before a state can lawfully resort to self-defence. Most international lawyers would agree that rockets launched against civilians that disrupt the social life of part of a country constitute an armed attack for the purposes of Article 51.
A case for self-defence is sometimes contested on factual grounds, for example with the argument that it was the other side that attacked first. In this case, critics of the Israeli position also advance two legal arguments.
First, they argue that the right of self-defence should be invoked only against another state, but not against a non-state entity like Gaza. State practice, especially since the attacks of 11 September 2001, militates against this interpretation of self-defence.
Secondly, some commentators maintain that Gaza is still subject to Israeli occupation because of the ongoing blockade, and that Israel cannot rely on self-defence in an occupied territory. Israel argues against this, pointing to its withdrawal from Gaza in 2005.
In a legal sense, "blockade" and "occupation" are concepts that have been understood in international law as distinct for some time. The conflation of the two is novel, and it runs into logical difficulties when its proponents characterise a ground operation as an "invasion".
The right of self-defence is no blank cheque. International law allows states to defend themselves only with force that is necessary and proportionate.
A common misperception is that proportionality in self-defence means an eye for an eye, a rocket for a rocket, or a casualty for a casualty. This is not so: there is no place in international law for using force in revenge.
In some cases, a necessary and proportionate response will entail the use of greater military force than was involved in the original attack; in other cases, it will be possible for a country to defend itself effectively with less force.
The principle of self-defence belongs to the body of international law that regulates resort to force or "going to war" (often referred to by the Latin term jus ad bellum, that is "law to war").
The other relevant body of international law regulates the conduct of hostilities once the conflict has started. It is known as the law of armed conflict (or the jus in bello that is "law in war").
International law maintains a strict separation between these two bodies of law.
Starting a war off on the right side of the law does not give a state more rights in the conduct of hostilities than its enemies. It is possible for a state that resorted to force lawfully to commit unlawful acts in the course of an armed conflict - and vice versa.
The law of armed conflict also limits the amount of force that states can lawfully use.
A key principle is that of humanity: belligerents should always avoid unnecessary suffering.
The principle of humanity must however be balanced against the principle of military necessity.
The legal manual used by the British armed forces says that military necessity allows a state to use force, unless otherwise prohibited, which is "required in order to achieve the legitimate purpose of the conflict, namely the complete or partial submission of the enemy at the earliest possible moment and with the minimum expenditure of life and resources".
The argument that the Israeli bombardments are ineffective because they have so far failed to completely stop rocket attacks can cut both ways.
Strategically, it may identify a fundamental weakness in the Israeli response and suggest the pursuit of non-forcible alternatives. But, from a military necessity angle, it may justify an escalation in the force that Israel uses so as to achieve the objective of averting the attacks.
Of course, the fact that the law authorises a certain action does not make it wise in a political or strategic sense.
A cornerstone in the law of armed conflict is the principle of distinction: parties to a conflict must distinguish between combatants and civilians at all times.
Various specific rules flesh out the content of this principle. Attacks on civilians and civilian objects are always banned. Attacks may be conducted against combatants or non-combatants who directly participate in hostilities, and against military objectives.
The principle of distinction also prohibits acts or threats of violence aimed at spreading terror among civilians, as well as attacks carried out with means which by their nature cannot target a specific military objective. The launching of missiles against southern Israel is said to breach distinction.
But when does an object become a legitimate military target?
International law defines military objectives as "objects which... make an effective contribution to military action... and whose total or partial destruction... offers a definite military advantage".
Rocket launchers and ammunition depots are in this category. Problems arise with so-called dual-use targets, such as the Serbian TV station bombed by Nato during the 1999 Kosovo War and the media building targeted by Israel in the course of Operation Pillar of Defence.
What about a building which contains a military objective, such as a rocket launcher, but which also houses civilians?
This example illustrates the importance of another pillar of the law of armed conflict: the principle of proportionality. Whenever there is a risk of loss of civilian life or damage to civilian property, belligerents are required to balance the anticipated military advantage with the risks posed to civilians and their property.
In some cases this may mean - as the former president of the International Court of Justice, Judge Rosalyn Higgins, wrote in one of her judgements - that "even a legitimate target may not be attacked if the collateral civilian casualties would be disproportionate to the specific military gain from the attack".
An attacker is also under a duty to call off an attack immediately if, in the course of it, it realizes that civilians would face excessive risk.
An attacker targeting military objectives in a densely populated area like Gaza must do everything feasible to verify the nature of the targets and avoid errors.
The practice of dropping leaflets or calling residents before a bombing is presented by Israel as evidence of its efforts to comply with these rules, although critics reply that these methods are not always effective and do not in any event prevent the destruction of civilian property.
A frequent accusation levelled against Hamas is that it deliberately endangers its own civilians by placing military objectives in their midst.
This is certainly a serious breach of the laws of armed conflict, but it does not mitigate Israel's obligation to continue to take all necessary precautions to minimise loss of civilian life.
All modern armed forces, including the Israel Defense Forces, have specialists on the law of armed conflict who are involved in the approval of targets.
Ultimately, the legality of a particular targeting decision will often depend on who is right about what happened. Was there a genuine military objective? Was it possible in the circumstances to hit that target while avoiding any loss of civilian life? What did the attacker know or should have known?
Establishing these facts during an armed conflict, or in its aftermath, is no easy feat.
However, when the attacker deliberately targets civilian objects, there is no version of the facts capable of justifying his actions under the laws of armed conflict.
The legal regulation of war is a sombre affair. This is an area of the law where starry-eyed idealism may be counterproductive.
It is better to remind ourselves that during an armed conflict, the law can at best reduce suffering but never eliminate it; and that wars, even those fought with a scrupulous observance of all the rules in the book, are always a scourge.
Guglielmo Verdirame is professor of International Law at the Department of War Studies and Dickson Poon School of Law, King's College London.