Just war theory (or Bellum iustum) is a doctrine of military ethics of Roman philosophical and Catholic origin, studied by moral theologians, ethicists and international policy makers, which holds that a violent conflict ought to meet philosophical, religious or political criteria.
The Indian epic, the Mahabharata, offers one of the first written discussions of a 'just war'. In it, one of five ruling brothers asks if the suffering caused by war can ever be justified, and then a long discussion ensues between the siblings, establishing criteria like proportionality (chariots cannot attack cavalry, only other chariots, no attacking people in distress), just means (no poisoned or barbed arrows), just cause (no attacking out of rage), and fair treatment of captives and the wounded.
In ancient Rome, a "just cause" for war might include the necessity of repelling an invasion, or retaliation for pillaging or a breach of treaty. War was always potentially nefas, "wrong, forbidden," and risked religious pollution and divine disfavor. A just war (bellum iustum) thus required a ritualized declaration by the fetial priests. More broadly, conventions of war and treaty-making were part of the ius gentium, the "law of nations," the customary moral obligations regarded as innate and universal to human beings.