Is there a term for the "treatment of foreigners as outsiders"?

Answer

One good technical term is 'out-group discrimination'.

Explanation

According to MW:

out-group noun
\ ˈau̇t-ˌgrüp
...
a group that is distinct from one's own and so usually an object of hostility or dislike — compare in-group sense 1

From sociology and evolutionary biology, we have the notion of in-group/out-group behavior, in which certain cognitive biases are inherent in human relations. Related to that are the notions of in-group favoritism and xenophobia which shows people may exhibit preference for those they are familiar with and fear of those they are not.

Justification

This phrase has some advantages. Because it is a technical term, it doesn't carry the same judgy connotation when characterizing someone, and unlike the term 'otherism' offered alongside by Lambie (which is a perfectly reasonable response), 'out-group discrimination' is widely in currency, which means that many people use and understand it. While a word by definition can mean anything, using language idiosyncratically often leads to confusion. It's helpful to use words that other people are already using. Note that google: "otherism" garners 26,600 hits at the time of this post, google: "out-group discrimination" registers more than 189 million results.

Additional References

  • usage: Out-Group Discrimination Fuels Anger, Risk-Taking and Vigilance.
  • google scholar: "out-group discrimination"

other and otherism, often other is capitalized: Other

And it can apply to foreigners, also.

treating a person as the other

Here is one description of it:

Otherism, in its tendency to dehumanize the “others”, has pervaded our culture, and perhaps has never been so discussed as in recent days. Mentions of racism, white supremacy, sexism, and classism wallpaper our national and local news.

otherism

In ART:

This investigation has led me to explore the commonalities and differences in the visual representation of racially constructed Others more broadly, and I keep reaching the same conclusion: no visual representation of people of color is ever innocent or powerful enough to challenge the socially defined images that frame them—depending on the given illusion—as marginal, as threats, as foreigners, as Others, as having too much culture or too little culture. On their own, artistic representations can do little to challenge racism. It takes structural change to create a visual revolution that can fully change and destroy our illusions.

Others and art

In FILM: City Archives (1977) 28 mins| Short

Foreman produced City Archives, a labyrinthine collage of image and language, at the invitation of the Walker Art Center in Minneapolis. The tape centers on the perspective of an outsider — the foreigner as Other — towards a city and its artifacts. Foreman’s signature visual and verbal puns and carefully composed compositions result in an often humorous dialogue on the role of documents as evidence, and the relationship of text and image. While questioning the positions from which one views information, Foreman constructs and then deconstructs the central metaphor of an archive as a receptacle of information and knowledge. Richard Foreman, filmmaker

One of the first to theorize about this was Julia Kristeva in her many works such as the book Black Sun. Ultimately, we project otherness onto others because we cannot handle those parts of ourselves that are other to us.

Julia Kristeva and otherism

The concept of the other in, among others,:

Philosophy, psychology, ethics, critical theory, etc. [NO psychiatry]

The Other, philosophy and psychoanalysis


Perhaps 'ostracism'? OED Lexico defines it as:

Exclusion from a society or group.

It can have meanings pertinent to the specific aspect of foreigner relations such as Linguistic ostracism while also having less targeted animosity present in words such as 'aversion'.


Perhaps you could use isolationism.

This is the definition:

i·so·la·tion·ism noun: isolationism a policy of remaining apart from the affairs or interests of other groups, especially the political affairs of other countries. "the country chose a policy of isolationism that made it a secondary player in world political events"

Isolationism is different from racism or xenophobia because it is saying the people tend to keep to themselves more, not having anything to do with hate.

Although it is often used in politics and international relations, it can also be used as you said in your question: that some specific cultures may be isolationist because they have been that way for hundreds of years.