Protesters attend an anti-Donald Trump, pro-immigration demonstration in New York City.Carlo Allegri / Reuters

It was coincidental, but clarifying, that London’s Sadiq Khan, the first Muslim elected mayor of a major Western city, landed in New York last Saturday night just hours after bombs allegedly set by a radicalized Muslim immigrant from Afghanistan rocked Manhattan and New Jersey.

From France and Germany to the United Kingdom and the United States, politics across the industrialized world are increasingly spinning around the same question: Are nations more likely to achieve security and prosperity by building walls or bridges to the outside world? The answer to this fundamental choice is dividing these nations, and others, not only along lines of generation, race and education, but also geography. As the insular nationalism symbolized by Donald Trump gains strength in the places that feel left behind in an integrating world, diverse global cities that thrive on connection are growing closer to their international peers-even as they grow more distant from the non-metropolitan areas of their own countries.

That was the important message of the visit by Khan, who arrived in New York after an earlier stop in Chicago. Like his hosts, Democratic mayors Bill de Blasio in New York and Rahm Emanuel in Chicago, Khan forcefully insists that integration, inclusion and openness to the world offer the best chance both to defuse terror and maximize economic growth.

That perspective shared by the mayors of almost all large U.S. cities and many others in Europe views immigrants as a source of economic and cultural vitality, trade as an engine of prosperity, and integration of Muslim communities as the central defense against radicalization and terror. “We play straight into the hands of the extremists and terrorists when we [say]…it’s not possible to hold Western values and to be a Muslim,” Khan wrote last week in the Chicago Tribune. “It makes it easier for terrorists to radicalize young people. And it makes us all less safe...”

All of this collides with the bristling defensive nationalism championed by Trump, France’s Marine Le Pen and nativist parties like UKIP in England and Alternative for Deutschland in Germany. These voices raise alarms against trade and immigration and portray greater restrictions and surveillance as the key to fighting Islamic terror. Stressing isolation over integration, Trump responded to the New York attacks by reiterating his calls for limiting Middle Eastern immigration and expanding law enforcement profiling of “people that maybe look suspicious.”

Almost everywhere, these messages have struggled in large urban areas and resonated in smaller places, especially those that have little tradition of racial diversity or have lost manufacturing jobs to trade. In last June’s “Brexit” referendum in the UK on the European Union, big majorities of residents in London and its thriving information-economy suburbs voted to remain, while those living in rural areas and economically strained smaller cities provided the leave campaign (which stressed anti-immigrant messages) with its narrow majority. In Berlin’s regional elections last weekend, the anti-immigrant, anti-globalization AfD party won only about 14 percent of the vote-enough to establish a foothold but less than it anticipated, or had carried in recent regional elections in rural East Germany. Likewise, the choice between Trump and Hillary Clinton is virtually certain to widen an already imposing metropolitan divide: in 2012, President Obama won America’s 100 largest counties by a combined margin of 12 million votes while losing the other 3,000 by about seven million votes.

Adjusting for national differences, the mayors of global cities are largely coalescing around agendas antithetical to the Trump vision. “There are 50 cities, maybe 100, that are the intellectual, cultural and economic engine of the world,” Emanuel said in an interview shortly after Khan left Chicago. “We are all working on the same things because we face similar opportunities. We have to make our cities competitive. The jobs and companies we talk about are not only global but mobile.”

This modern urban agenda revolves around investment in infrastructure and education (ranging from expanded pre-school to tuition-free post-secondary education); welcoming immigrants; support for small business and information-age technology start-ups; promoting more dense development (Khan toured Chicago’s impressive riverfront development as a possible model for the Thames); embracing renewable energy as both an economic engine and environmental imperative; and with only a few exceptions (like deBlasio) supporting more international trade. The common theme, Emanuel says, is to create a “platform for private sector growth” while advancing equity and inclusion.

As Khan pointedly noted during his visit, many cities are failing to achieve that “social integration.” Many major cities are now divided between white-collar professionals who are thriving, often in rejuvenated downtown neighborhoods, and lower-income minority communities much more disconnected from opportunity. Research consistently shows that cities face high levels of income inequality and economic and racial segregation in both housing and schools. And the entrenched conflict in Chicago symbolizes the systematic alienation of minority communities from law enforcement in many metropolitan areas.

Yet, for all these failings, mayors across the world are combating these trends with social and economic strategies centered on promoting greater connection, both at home and internationally. By welcoming ideas, products and people from around the globe, and insisting that only extending opportunity to all communities can provide lasting security or prosperity, they are formulating an inclusive alternative to the zero-sum ethnic nationalism of Trump and his European counterparts. In years ahead, the battle over whether Western societies are more likely to succeed as open or closed is likely to unfold largely as a struggle between town and country.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.