It's even stranger considering the ancient peoples in the Middle/Near East practiced polytheism but Islam worships the Abrahamic God. I say depicted at odds long before the 20th century.
Mesopotamia is seen as the cradle of Western Civilization but is the West's enemy when fighting the Greeks.
In a word: racism.
The much longer answer involves the development of the concept of the “west” (meaning Europe) during the Enlightenment and post-Enlightenment period, in which the understanding of history was that Europe, having industrialized, discovered the rest of the globe (that people already lived in these places was irrelevant) and then colonized or economically came to dominate it, and having overcome the supposed ignorances of a religious based society by developing secular humanist philosophy and secular concepts of government (again, the fact that it is argued that neither of these could have developed outside of a Christian society is irrelevant) must therefore have done something ‘right’ that the rest of the world did not do.
History, therefore, was not an evenhanded quest to uncover some sort of objective truth, but rather a teleological (fancy word meaning “starting from a certain presupposition and working backwards from there”) exploration of the factors that made Europe successful. This is when it was decided that Greece was the origin of democracy. Egypt and Mesopotamia were western insomuch as their ideas Interplayed with Greece and then Rome, but, since Islamic lands had come to be dominated by Europe (or languished behind, as the Ottoman Empire was understood to have done), Islam therefore could not be part of this tradition.
This is also where the simplistic critique of Islam as being an all-encompassing belief structure in which self-criticism and dissent cannot happen comes from; ironically it is based on their own misunderstanding of what Christian Europe was like before the Enlightenment. It was also informed by Islam, through its presence in Spain, Sicily, and the Ottoman lands, being the ‘Other’ against which Europe came to define itself: “they are what we are not.”
It’s also interesting to note that the United States, for example, was extremely reluctant to let Italians and Greeks immigrate in the early 20th century on the basis that they weren’t white enough to fit in to Anglo-American Protestant society. So, at some point, those countries also fell from grace—when they speak of “Europe” they really meant Northern Europe.
Anyway, one could argue that it’s not necessarily racism but it was definitely motivated by a notion of (northern) European society and looking for the factors that caused this superiority.