Wartime sexual violence
The Lieber Code (1863) was the first codification of the international customary laws of land war and an important step towards humanitarian law. The Lieber Code emphasized protection of civilians and stated that "all rape... [is] prohibited under the penalty of death", which was the first prohibition of rape in customary humanitarian law.

20th century: During the 20th century, international legal procedures attempted to prevent and prosecute perpetrators of war rape. Similarly, individual states developed laws pertaining to war rape's victims and perpetrators.
The prohibition of rape was excluded from the Geneva Conventions and was deliberately left vague by the Hague Conventions. Article 46 of the Hague Conventions of 1899 and 1907 regarding Land Warfare required only that "[f]amily honour and rights [and] the lives of persons... must be respected" by the occupying powers.
After World War I, the Commission of Responsibilities, set up in 1919 to examine the atrocities committed by the German Empire and the other Central Powers during the war, found substantial evidence of sexual violence and subsequently included rape and forced prostitution among the violations of the laws and customs of war. Efforts to prosecute failed.

World War II: The Nuremberg and Tokyo Tribunals became the first international courts of real significance. The victorious Allied powers established them in 1945 and 1946 respectively to prosecute the major war criminals of the European Axis powers (in fact only Germans) and of Japan for crimes against peace, war crimes, and crimes against humanity. The possibility of prosecuting sexual violence as a war crime was present because of the recognition of war rape as serious violation of the laws of war in the Hague Conventions of 1899 and 1907 assertion that "[f]amily honour and rights [and] the lives of persons... must be respected."
While the Nuremberg Tribunals failed to charge Nazi war criminals with rape, witnesses testified about it occurring. Several of the testimonies of victims of sexual violence during the Holocaust were by Jewish men and women. Previous war crimes trials had prosecuted for sex crimes, hence war rape could have been prosecuted under customary law and/or under the IMT (International Military Tribunals) Charter's Article 6(b): "abduction of the civilian population.... into slavery and for other purposes" and "abduction unjustified by military necessity". Similarly, it would have been possible to prosecute war rape as crime against humanity under Article 6(c) of the Nuremberg Charter: "other inhumane acts" and "enslavement". However, notwithstanding evidence of sexual violence in Europe during World War II, a lack of will led to rape and sexual violence not being prosecuted at the Nuremberg Tribunals.
According to records, at least 34 140 European women were forced to  prostitution during the German occupation of their countries, along with concentration camp female prisoners. In many cases, girls and women were abducted from the streets of occupied cities during German patrols.
The International Military Tribunal for the Far East did convict Japanese officers "of failing to prevent rape" in the Nanjing Massacre. The tribunal, in Tokyo, prosecuted cases of sexual violence and war rape as war crimes under the wording "inhumane treatment", "ill-treatment", and "failure to respect family honour and rights". According to the prosecution, in excess of 20,000 women and girls were raped during the first weeks of the Japanese occupation of the Chinese city of Nanjing. The War Crimes Tribunal in Tokyo included accounts of sexual violence crimes in the trial testimonies as well as public records. On a national level, a commander of the 14th Area Army, General Yamashita, was convicted for, inter alia, "rape under his command". Some 35 Dutch comfort women brought a successful case before the Batavia Military Tribunal in 1948.
It is well known that brutal mass rapes were committed against German women; both during and after World War II. According to some estimates, over 100,000 women were raped by Soviet soldiers in Berlin both during and after the Battle of Berlin.
The phrase "from eight to 80" was used to describe potential victims of Soviet mass-rape. "Red Army soldiers don't believe in 'individual liaisons' with German women," wrote the playwright Zakhar Agranenko in his diary when he was serving as an officer of the marine infantry in East Prussia. "Nine, ten, twelve men at a time – they rape them on a collective basis." Rape was regarded by men in the Soviet army as a well-deserved form of punishment, whether the civilians had anything to do with the war or not. In total, historians estimate that over two million German women were raped.
Rapes were also committed against allied nationals during the war; for example, Marocchinate (Italian for "Moroccan' deeds") is a term which is applied to the mass rape and killings of Italian civilians by the Moroccan Goumiers, colonial troops of the French Expeditionary Corps (FEC), commanded by General Alphonse Juin, after the Battle of Monte Cassino in Italy during World War II. It was estimated that 2,000 women and 600 men were raped and most of these crimes took place in the rural area between Naples and Rome.
Following World War II, the judges at the Nuremberg trials in 1946 stated that the laws of war only applied to enemy nationals, not that of an ally, meaning such acts were not war crimes.

1949 Geneva Conventions: Common Article 3 of the 1949 Geneva Conventions provides that "violence to life and person, in particular murder of all kinds, mutilation, cruel treatment and torture" and "outrages upon personal dignity, in particular humiliating and degrading treatment" are prohibited under any circumstance whatsoever with respect to persons who are hors de combat or who are not taking part of direct hostilities in non-international conflicts.
Article 27 of the 1949 Fourth Geneva Convention explicitly prohibits wartime rape and enforced prostitution of protected persons in international conflicts.
The prohibitions outlined in the 1949 Geneva Conventions were reinforced by the 1977 Additional Protocols I and II to the 1949 Geneva Conventions.
Article 4 of the Fourth Geneva Convention excludes civilians under their own national authority, nationals of a state not party to the convention, neutral persons living in the belligerent nation, and allied nationals from protection under the convention. Non-protected rape victims are instead protected by international human rights law to which their home or the offending foreign state may be a party to.

International Criminal Tribunal for Rwanda: In 1998, the International Criminal Tribunal for Rwanda established by the United Nations made landmark decisions defining genocidal rape (rape intended to affect a population or culture as a whole) as a form of genocide under international law. In the trial of Jean-Paul Akayesu, the mayor of Taba Commune in Rwanda, the Trial Chamber held that "sexual assault formed an integral part of the process of destroying the Tutsi ethnic group and that the rape was systematic and had been perpetrated against Tutsi women only, manifesting the specific intent required for those acts to constitute genocide."
Judge Navanethem Pillay, who went on to become the United Nations High Commissioner for Human Rights between 2008 and 2014, said in a statement after the verdict: "From time immemorial, rape has been regarded as spoils of war. Now it will be considered a war crime. We want to send out a strong message that rape is no longer a trophy of war." An estimated 500,000 women were raped during the 1994 Rwandan genocide.
Professor Paul Walters in his April 2005 statement of support of Pillay's honorary doctorate of law at Rhodes University wrote:

Under her presidency of the Rwanda Tribunal, that body rendered a judgment against the mayor of Taba Commune which found him guilty of genocide for the use of rape in "the destruction of the spirit, of the will to live, and of life itself."
The Akayesu judgement includes the first interpretation and application by an international court of the 1948 Convention on the Prevention and Punishment of the Crime of Genocide. The Trial Chamber held that rape (which it defined as "a physical invasion of a sexual nature committed on a person under circumstances which are coercive") and sexual assault constitute acts of genocide insofar as they were committed with the intent to destroy, in whole or in part, a targeted group, as such. It found that sexual assault formed an integral part of the process of destroying the Tutsi ethnic group and that the rape was systematic and had been perpetrated against Tutsi women only, manifesting the specific intent required for those acts to constitute genocide.
In September 1999, the United Nations published a "Report of the International Criminal Tribunal for the Prosecution of Persons Responsible for Genocide and Other Serious Violations of International Humanitarian Law Committed in the Territory of Rwanda and Rwandan Citizens Responsible for Genocide and Other Such Violations Committed in the Territory of Neighboring States between 1 January and 31 December 1994". The report states that on 2 September 1998, Trial Chamber I of the International Criminal Tribunal for Rwanda, composed of Judges Laïty Kama, Presiding, Lennart Aspegren and Navanethem Pillay, found Jean Paul Akayesu guilty of 9 of the 15 counts proffered against him, including genocide, direct and public incitement to commit genocide and crimes against humanity, murder, torture, rape, and other inhumane acts.