Last month, the world got to see the first image ever taken of a black hole. This groundbreaking moment in astronomy was made possible by international collaboration on a huge scale: eight linked telescopes in locations ranging from Chile to Spain to the South Pole produced the data to create the images. The project involved scientific institutions from every continent — a truly global effort.

International projects on this kind of scale are a relatively recent phenomenon, but cross-cultural collaboration has been a central feature of scientific practice for millennia. Ever since the beginnings of scientific research in the ancient world, scholars have traveled to learn, to share their ideas and to work with other like-minded people. Much of our scientific understanding of the world today emerged from these collaborations. And yet today, such cross-cultural work is under threat, as anti-immigrant, nationalist policies threaten a loss of intellectual resources that could lead to a significant reduction in scientific advances.

In the Classical period, Alexandria was the city scholars gravitated toward. Situated on the northern coast of Egypt, it was the center of the ancient Mediterranean intellectual world and home of the famous library. King Ptolemy I took over the city in 305 B.C. on the death of its founder, Alexander the Great. He immediately began transforming it into a vibrant seat of learning, amassing scrolls for his collections, tempting the brightest minds to make the city their home.

The knowledge stored in the library was also the product of many civilizations: Babylonian, Egyptian, Jewish, Persian, Hellenistic and later on, Roman. This made it an incredibly valuable, pan-cultural resource, enabling some of the most important scientific books of all time to be written there, using data from much older traditions. The library helped Alexandria to retain its reputation as an unparalleled center of learning for several centuries. Six hundred years after Ptolemy I died, clever young men were still boarding ships bound for the great city so that they could study Homer, human skeletons and more.

A reputation for openness and tolerance, for prioritizing the pursuit of knowledge above all else, has been a defining feature of scholarship ever since. Scientific progress can, of course, happen without it, but if a country wants to become a world leader in any of these fields, it must be able to attract the best and brightest to its shores.

For the last 200 years or so, the United States has been one of the premier destinations for scientific research, driven not only by the country’s extraordinary economic growth and its free market, which encouraged entrepreneurship and innovation, but also by its welcoming, positive attitude and a worldwide reputation as the “land of the free.”

But this status is now under threat. Recent changes to immigration policy have implemented bans on people entering the United States from certain (mainly Muslim) countries, while the administrative load and wait times for entry into the country have been increased across the board. Those with Arabic names often find themselves subject to increased scrutiny and checks when applying to work or study in America, and recently this discriminatory process has widened to include Chinese nationals.

These factors are already having an impact on the country’s reputation in scholarly circles. People are worried about the difficulties of traveling to the United States to study and work, so fewer are applying, choosing alternative destinations instead.

With immigrants making up roughly 25 percent of science and technology workers in the United States, the scientific community is understandably concerned. In 2017 Jeremy Levin, chief executive of Ovid Therapeutics (himself an immigrant from South Africa via Britain), published an open letter in the international journal Nature, signed by 150 biotech leaders, stating their opposition to the Trump administration’s ban on immigration from selected countries and voicing their concerns over the effect it could have on the U.S. biopharma industry and its position as a world leader in the field.

The next stage in the process, one that is already happening in Brexit-beleaguered Britain, is that immigrants already living there have begun to feel unwelcome, causing some to leave. Britain is looking for about 10,000 doctors to work in the National Health Service, and the vast majority of these will have to come from other countries.

The colloquial term for the massive loss of highly qualified professionals is a “brain drain,” something that has long been a feature of the academic world. When conditions change and become hostile to the pursuit of knowledge for whatever reason — racial discrimination, religious opposition, political instability, insufficient funding — scholars, scientists and students will leave and go in search of somewhere else they can follow their passion.

This has happened many times in history. In the 10th century, the Andalusian city of Córdoba in southern Spain was one of the most beautiful, civilized places on Earth, ruled by enlightened caliphs, inhabited by the brightest physicians, astronomers and mathematicians, home to libraries, palaces and courtyards filled with flowers and fountains.

But in 976, the city’s ruler, Al-Hakam II died. His son and heir was a vulnerable 11-year-old, leaving the path clear for his vizier, al-Mansur, to seize power. Under the spell of religious conservatives, al-Mansur devastated the city, ransacking many of the libraries and destroying any text he deemed heretical, especially those on ancient scientific subjects like astronomy.

A few scholars managed to escape the chaos, taking as many books as they could carry with them. They fled to other cities in the region — Seville, Granada, Zaragoza, Toledo — where they were welcomed by local rulers keen to increase their own scholarly prestige. In the following decades learning blossomed in their courts. Zaragoza in particular became famous for the study of mathematics and philosophy, at the expense of Córdoba, which never regained its position.

As this example illustrates, religion and science have often been uncomfortable bedfellows. The anti-Muslim sentiment that lies at the heart of current U.S. immigration restrictions has a long-standing and shameful history.

By 1492, the Iberian Peninsula had been entirely reconquered by Christian Europeans. The tolerance and freedom originally promised to Muslims and Jews had been swept away by a tide of religious fervor and xenophobia, with violence on all sides. In 1499, Ximénes de Cisneros, a fanatical Catholic priest tasked with converting and subduing the inhabitants of Granada, ordered every book in Arabic to be piled up the central square and set on fire, a conflagration of some seven centuries of Islamic culture. This policy’s success can be measured by the fact that there was only a tiny handful of Arabic manuscripts left in Spain in the 17th century.

Looking back through the long history of ideas, it is striking that almost every great center of learning built its success on fostering a degree of tolerance and open-mindedness toward foreigners, of putting scholarship first. It is difficult to overestimate the importance of having that reputation, the magical aura of excellence, of being the best place to work and study, the place scholars move toward when they have exhausted opportunities in their own country. Once lost, it can be extremely difficult to regain — something U.S. policymakers should keep in mind.