This dilemma is both ethical and practical. It is often "resolved" by applying - explicitly or implicitly - the principle of "over-riding affiliation". As usual, Judaism was there first, agonizing over similar moral conflicts. Two Jewish sayings amount to a reluctant admission of the relativity of moral calculus: "One is close to oneself" and "Your city's poor denizens come first (with regards to charity)".
One's proper conduct, in other words, is decided by one's self-interest and by one's affiliations with the ingroups one belongs to. Affiliation (to a community, or a fraternity), in turn, is determined by one's positions and, to some extent, by one's oppositions to various outgroups.
What are these "positions" (ingroups) and "oppositions" (outgroups)?
The most fundamental position - from which all others are derived - is the positive statement "I am a human being". Belonging to the human race is an immutable and inalienable position. Denying this leads to horrors such as the Holocaust. The Nazis did not regard as humans the Jews, the Slavs, homosexuals, and other minorities - so they sought to exterminate them.
All other, synthetic, positions are made of couples of positive and negative statements with the structure "I am and I am not".
But there is an important asymmetry at the heart of this neat arrangement.
The negative statements in each couple are fully derived from - and thus are entirely dependent on and implied by - the positive statements. Not so the positive statements. They cannot be derived from, or be implied by, the negative one.
Lest we get distractingly abstract, let us consider an example.
Study the couple "I am an Israeli" and "I am not a Syrian".
Assuming that there are 220 countries and territories, the positive statement "I am an Israeli" implies about 220 certain (true) negative statements. You can derive each and every one of these negative statements from the positive statement. You can thus create 220 perfectly valid couples.
"I am an Israeli ..."
"I am not ... (a citizen of country X, which is not Israel)".
You can safely derive the true statement "I am not a Syrian" from the statement "I am an Israeli".
Can I derive the statement "I am an Israeli" from the statement "I am not a Syrian"?
Not with any certainty.
The negative statement "I am not a Syrian" implies 220 possible positive statements of the type "I am ... (a citizen of country X, which is not India)", including the statement "I am an Israeli". "I am not a Syrian and I am a citizen of ... (220 possibilities)"
Negative statements can be derived with certainty from any positive statement.
Negative statements as well as positive statements cannot be derived with certainty from any negative statement.
This formal-logical trait reflects a deep psychological reality with unsettling consequences.
A positive statement about one's affiliation ("I am an Israeli") immediately generates 220 certain negative statements (such as "I am not a Syrian").
One's positive self-definition automatically excludes all others by assigning to them negative values. "I am" always goes with "I am not".
The positive self-definitions of others, in turn, negate one's self-definition.
Statements about one's affiliation are inevitably exclusionary.
It is possible for many people to share the same positive self-definition. About 6 million people can truly say "I am an Israeli".
Affiliation - to a community, fraternity, nation, state, religion, or team - is really a positive statement of self-definition ("I am an Israeli", for instance) shared by all the affiliated members (the affiliates).
One's moral obligations towards one's affiliates override and supersede one's moral obligations towards non-affiliated humans. Ingroup bias carries the weight of a moral principle.
Thus, an American's moral obligation to safeguard the lives of American fighter pilots overrides and supersedes (subordinates) his moral obligation to save the lives of innocent civilians, however numerous, if they are not Americans.
The larger the number of positive self-definitions I share with someone (i.e., the more affiliations we have in common) , the larger and more overriding is my moral obligation to him or her.
I have moral obligations towards all other humans because I share with them my affiliation to the human species.
But my moral obligations towards my countrymen supersede these obligation. I share with my compatriots two affiliations rather than one. We are all members of the human race - but we are also citizens of the same state.
This patriotism, in turn, is superseded by my moral obligation towards the members of my family. With them I share a third affiliation - we are all members of the same clan.
I owe the utmost to myself. With myself I share all the aforementioned affiliations plus one: the affiliation to the one member club that is me.
But this scheme raises some difficulties.
We postulated that the strength of one's moral obligations towards other people is determined by the number of positive self-definitions ("affiliations") he shares with them.
Moral obligations are, therefore, contingent. They are, indeed, the outcomes of interactions with others - but not in the immediate sense, as the personalist philosopher Emmanuel Levinas suggested.
Rather, ethical principles, rights, and obligations are merely the solutions yielded by a moral calculus of shared affiliations. Think about them as matrices with specific moral values and obligations attached to the numerical strengths of one's affiliations.
Some moral obligations are universal and are the outcomes of one's organic position as a human being (the "basic affiliation"). These are the "transcendent moral values".
Other moral values and obligations arise only as the number of shared affiliations increases. These are the "derivative moral values".
Moreover, it would wrong to say that moral values and obligations "accumulate", or that the more fundamental ones are the strongest.
On the very contrary. The universal ethical principles - the ones related to one's position as a human being - are the weakest. They are subordinate to derivative moral values and obligations yielded by one's affiliations.
The universal imperative "thou shall not kill (another human being)" is easily over-ruled by the moral obligation to kill for one's country. The imperative "though shall not steal" is superseded by one's moral obligation to spy for one's nation. Treason is when we prefer universal ethical principles to derivatives ones, dictated by our affiliation (citizenship).
This leads to another startling conclusion:
There is no such thing as a self-consistent moral system. Moral values and obligations often contradict and conflict with each other.
In the examples above, killing (for one's country) and stealing (for one's nation) are moral obligations, the outcomes of the application of derivative moral values. Yet, they contradict the universal moral value of the sanctity of life and property and the universal moral obligation not to kill.
Hence, killing the non-affiliated (civilians of another country) to defend one's own (fighter pilots) is morally justified. It violates some fundamental principles - but upholds higher moral obligations, to one's kin and kith.
Note - The Exclusionary Conscience
The self-identity of most nation-states is exclusionary and oppositional: to generate solidarity, a sense of shared community, and consensus, an ill-defined "we" is unfavorably contrasted with a fuzzy "they". While hate speech has been largely outlawed the world over, these often counterfactual dichotomies between "us" and "them" still reign supreme.
In extreme - though surprisingly frequent - cases, whole groups (typically minorities) are excluded from the nation's moral universe and from the ambit of civil society. Thus, they are rendered "invisible", "subhuman", and unprotected by laws, institutions, and ethics. This process of distancing and dehumanization I call "exclusionary conscience".
The most recent examples are the massacre of the Tutsis in Rwanda, the Holocaust of the Jews in Nazi Germany's Third Reich, and the Armenian Genocide in Turkey. Radical Islamists are now advocating the mass slaughter of Westerners, particularly of Americans and Israelis, regardless of age, gender, and alleged culpability. But the phenomenon of exclusionary conscience far predates these horrendous events. In the Bible, the ancient Hebrews are instructed to exterminate all Amalekites, men, women, and children.
In her book, "The Nazi Conscience", Claudia Koontz quotes from Freud's "Civilization and its Discontents":
"If (the Golden Rule of morality) commanded 'Love thy neighbor as thy neighbor loves thee', I should not take exception to it. If he is a stranger to me ... it will be hard for me to love him." (p. 5)
Note - The Rule of Law, Discrimination, and Morality
In an article titled "Places Far Away, Places Very near - Mauthausen, the Camps of the Shoah, and the Bystanders" (published in Michael Berenbaum and Abraham J. Peck (eds.) - The Holocaust and History: The Known, the Unknown, the Disputed, and the Reexamined - Bloomington and Indianapolis: Indiana University Press, 1998), the author, Gordon J. Horwitz, describes how the denizens of the picturesque towns surrounding the infaous death camp were drawn into its economic and immoral ambit.
Why did these law-abiding citizens turn a blind eye towards the murder and mayhem that they had witnessed daily in the enclosure literally on their doorstep? Because morality is a transaction. As Rabbi Hillel, the Talmudic Jewish sage, and Jesus of Nazareth put it: do not do unto others that which you don't want them to do to you (to apply a utilitarian slant to their words).
When people believe and are assured by the authorities that an immoral law or practice will never apply to them, they don't mind its application to others. Immoral acts inevitably devolve from guaranteed impunity. The Rule of Law does not preclude exclusionary or discriminatory or even evil praxis.
The only way to make sure that agents behave ethically is by providing equal treatment to all subjects, regardless of race, sex, religious beliefs, sexual preferences, or age. "Don't do unto others what you fear might be done to you" is a potent deterrent but it has a corollary: "Feel free to do unto them what, in all probability, will never be done to you."
Nazi atrocities throughout conquered Europe were not a-historical eruptions. They took place within the framework of a morally corrupt, permissive and promiscuous environment. Events such as Dir Yassin, My Lai, and Rwanda prove that genocide can and will be repeated everywhere and at all times given the right circumstances.
The State of Israel (Dir Yassin) and the United States (My Lai) strictly prohibit crimes against humanity and explicitly protect civilians during military operations. Hence the rarity of genocidal actions by their armed forces. Rwanda and Nazi Germany openly condoned, encouraged, abetted, and logistically supported genocide.
Had the roles been reversed, would Israelis and Americans have committed genocide? Undoubtedly, they would have. Had the USA and Israel promulgated genocidal policies, their policemen, secret agents, and soldiers would have mercilessly massacred men, women, and children by the millions. It is human nature. What prevents genocide from becoming a daily occurrence is the fact that the vast majority of nations subscribe to what Adolf Hitler derisively termed "Judeo-Christian morality."