Hamas and Israel have both been accused of breaking international law during their latest conflict, and the United Nations says it is collecting evidence of war crimes by all sides.
Enforcing the law amid the fog of war is difficult. Holding perpetrators to account once conflicts are over has often proved elusive.
Here is a look at some of the issues.
WHAT ARE THE RULES OF WAR?
The rules of armed conflict are governed by a set of internationally recognised laws and resolutions, including the United Nations charter, which prohibits aggressive wars but allows countries the right to self-defence.
Battlefield behaviour has international humanitarian laws including the Geneva Conventions, drawn up after World War II and agreed on by almost every nation.
The four conventions agreed upon in 1949 set out that civilians, the wounded and prisoners must be treated humanely in wartime. They ban murder, torture, hostage-taking and “humiliating and degrading treatment” and require fighters to treat the other side's sick and wounded.
The rules apply both to wars between nations and conflicts, like that between Israel and Hamas, in which one of the parties is not a state.
Another key document in the law of war is the founding Rome Statue of the International Criminal Court, which defines as war crimes acts including intentional attacks on civilians, civilian settlements or humanitarian workers, destroying property where not militarily necessary, sexual violence and unlawful deportation.
Other agreements ban certain types of weapons, such as chemical or biological munitions. Most but not all countries have signed up to these.
HAS HAMAS COMMITTED WAR CRIMES?
Hamas has fired thousands of rockets at Israeli towns and cities, and on October 7 sent hundreds of gunmen across the border from Gaza. They attacked and killed civilians -- including children and elderly people -- in their homes and neighbourhoods and kidnapped scores of others. Israel says at least 1,400 people died and 199 others were abducted.
Haim Abraham, a lecturer in law at University College London, said the evidence of crimes is clear.
“They massacred civilians at their homes. They kidnaped civilians, taking them hostage. All of these things are clearly war crimes,” he said.
Jeanne Sulzer, a lawyer with the Commission for International Justice of Amnesty International France, said the Geneva Conventions state that “civilians should never be taken hostage. If they are, that may be characterised as a war crime”.
HAS ISRAEL'S RESPONSE BEEN LEGAL?
The Israeli military has pounded Hamas-ruled Gaza with airstrikes, blocked deliveries of food, water, fuel and electricity and told people to leave the northern half of the strip ahead of a possible ground invasion.
Gaza authorities say 2,800 people have died and 11,000 have been injured during days of bombardment.
Critics accuse Israel of collectively punishing Gaza's 2 million residents.
The Geneva-based International Committee of the Red Cross has said the instruction for hundreds of thousands of people to leave their homes, “coupled with the complete siege explicitly denying them food, water, and electricity, are not compatible with international humanitarian law”.
The Israeli army says it follows international law and strikes only legitimate military targets as it seeks to root out militants who embed themselves among the civilian population.
Human Rights Watch has accused Israel of using munitions containing white phosphorus. The incendiary substance is not banned, but its use in densely populated areas has been widely condemned. The Israeli Defence Force has denied using white phosphorus as a weapon in Gaza.
CAN LAWBREAKERS BE HELD TO ACCOUNT?
A United Nations Commission of Inquiry says it is “collecting and preserving evidence of war crimes committed by all sides” in the current conflict. That evidence could be added to an ongoing investigation by the International Criminal Court into the situation in the Palestinian territories.
The Netherlands-based ICC has the power to prosecute nations' officials for violations and order compensation for victims. But some countries – including the United States, Russia and Israel -- do not recognise the court's jurisdiction, and the ICC does not have a police force to execute arrest warrants.
ARE THERE ANY OTHER ROUTES?
While the ICC is the only permanent international tribunal set up to prosecute war crimes, other international courts including the International Court of Justice and the European Court of Human Rights can hear cases related to alleged violations.
So can domestic courts in Israel or elsewhere, Under US law, American victims could try to bring claims for compensation against Hamas in US courts.
As with Russia's invasion of Ukraine, the prospect of prosecuting war crimes in the current conflict seems remote. But Amnesty International's Sulzer said “legal initiatives are already a reality”.
She said French national and dual citizen victims of the Hamas attacks have already filed complaints in French courts.
Breaches of international law can also trigger sanctions – such as those imposed on Russia by the United States, the European Union and others over the invasion of Ukraine – and in rare cases draw U.N.-authorized military intervention.