This summary is based on information from God's War by Christopher Tyerman (Cambridge: Harvard University Press, 2006).
In the 4th century BCE, the Greek philosopher Aristotle outlined what he considered to be acceptable categories of warfare. In his work, Politics, he declared that war was never to be an end unto itself, but was legitimate when waged under certain circumstances: as a form of self-defense, to secure an empire, or to enslave non-Hellenistic peoples. Later, the notion of war waged for the sake of a peaceful, prosperous, and secure state was enshrined in Roman Law, and the concept of "just war" was born.
This Greco-Roman concept of just war was not explicitly religious in nature. Early Christians developed their own theological understanding of war. Some Christians derived the concept of war by divine right from the Judaic tradition, whose scriptures tell stories of the Israelite people going to battle with God on their side. There were also Christian theologians who rejected the morality of war, favoring a more pacifist stance. Among them was Origen, a 3rd century CE theologian who argued that the battles of the Hebrew scriptures were allegorical in nature.
The definition of "just war" changed with the conversion of the Roman state to Christianity in the 4th century CE. The idea of war fought for God and with God's approval became merged with the political definition of a just war. Augustine of Hippo, in the 5th century, stated that sin was the cause of war, but that sin could also be combated by war, as long as the intent of the conflict was to establish a Christian peace. He established four essential components of just war: a just cause, an aim of defending or recovering rightful property, sanctioning by a legitimate authority, and fighters who are motivated by right intent.
The concept of divinely justified war had a powerful influence during the period of the Crusades and the Inquisition (beginning around 1100 CE). During that period, the image of Christ was often transformed into a warrior-hero, the model of a righteous soldier. Thomas Aquinas, in the 13th century, made important contributions to the development of Christian just war theory, and the Catholic church has since added these elements to their doctrine:
The damage inflicted by the aggressor on the nation or community of nations must be lasting, grave, and certain; all other means of putting an end to it must have been shown to be impractical or ineffective; there must be serious prospects of success; the use of arms must not produce evils and disorders graver than the evil to be eliminated. The power of modern means of destruction weighs very heavily in evaluating this condition. — Catechism of the Catholic Church
Just war theory is not only a Roman Catholic doctrine, however. It has been heavily debated across the spectrum of Christianity. After World War II, the concept of a just war was reexamined in light of the Holocaust. Twentieth-century theologian Reinhold Niebuhr speaks for many modern just war theorists when he says:
It has since become quite apparent that tyranny would have conquered the world if the material resources of civilization had not been organized and harnessed so that force could be met by superior force. — from Love and Justice, part III, section 41)