Greeting Strangers
We learn in the Mishna that a person should be prompt to greet others: "Rebbe Matia ben Charash says, be first to greet [literally, say Shalom to] all people" (Avot 4:16). The reason for this is elaborated in the gemara in Berakhot (17a): "A pearl [valuable adage] in the mouth of Abaye: A person should always be sly in reverence, for 'A soft reply turns away wrath' (Mishlei 15:1), and increase peace among his brothers and his relatives and with every man, and even a stranger in the marketplace, so that he may be beloved on high and esteemed below, and should be accepted among human beings. It was said of Rabban Yochanan ben Zakai that no one ever preceded him in a greeting [of Shalom], even a stranger in the marketplace."
We see that the reason for trying to be the first to greet others is simply in order to be friendly to others and accepted among them. (A passage with a parallel message is found in Kiddushin 33a.)
The Shulchan Arukh brings an almost identical halakha, but with a very different message: "It is at all times forbidden to double a greeting [literally, Shalom] to a pagan. Therefore it is best to precede to greet him, so that the pagan won't precede him and obligate him to double the greeting" (SA YD 148:10).
(It seems that the custom in the time of the Mishna was that when greeted, a person would reply with a double greeting. This is similar to the custom in Yiddish, where when a person says "gut morgan" good morning, the standard reply is "gut morgan, gut yahr" good morning and a good year. See Derishah YD 148:6.)
Here it seems like greeting the stranger is in itself a negative thing. However, since delaying the greeting would obligate us to say an even more elaborate one, we compromise by being the first to say Shalom. This halakha is based on the gemara in Gittin (62a) which forbids doubling Shalom to a pagan, and relates that Rav Chisda used to precede saying Shalom; evidently this was in order to avoid having to double the greeting.
A number of Rishonim resolve this paradox by explaining that the gemara in Gittin is talking about a greeting which refers to Hashem. (This makes sense in the context of the passage there, which previously stated that we may encourage non-Jews in their agricultural work in the Sabbatical year, but only by directly urging them on without saying "Shalom" which is a name of Hashem.) Whereas the passage in Berakhot refers to an ordinary polite greeting.
We should always be eager to show our desire for friendly relations with all people by being the first to greet them. We seek partnership with other nations in everything relating to creating an orderly and enlightened society. This was the custom of Rabban Yochanan ben Zakkai who was always the first to greet others.
However, when the greeting has religious overtones, we need to be more careful. It is not possible for us to establish a true religious partnership with members of other religions; at most we can relate to a certain foundational level of belief in God. In this case it would really be better to avoid any greeting with religious overtones. Even so, if we are confronted with such a greeting, we need to acknowledge the level of common belief that does exist, and would be obligated to reinforce it "to double Shalom". Therefore, the best course is to preempt such an "ecumenical" invitation with a simple non-committal greeting of Shalom.
Rabbi Meir's book Meaning in Mitzvot is now available as an e-book through Amazon, ibooks, Google Play and B&N.