A few years ago, on my way from eastern Oregon to Salt Lake City, I pulled off I-84 in Boise, Idaho, a place I knew only from a Lynyrd Skynyrd lyric. I strolled downtown and, in a farmers’ market smelling of lemon sage and lavender, found the best artisanal granola bars west of Burlington, Vermont. As I scanned the pale young crowd and noted the vendors’ earnestly precious names (Hoot ’n’ Holler Urban Farm, Blue Feather Bakery), it occurred to me how much the scene resembled a Saturday morning at Smorgasburg, or at Ferry Plaza in San Francisco, or in Boulder, Sante Fe, or Portland, Maine. The vibe was relaxed, prosperous, and gently urban. Around that time, the real-estate blog Estately ranked Boise fifth on its list of best cities for conservatives: “The tech jobs are plentiful, the Mormonism abundant, there are no restrictions on assault weapons, and there’s plenty of art, music, and theater.” And yet, like most red-state cities, Idaho’s capital is remarkably short on conservatives. Last November, while Hillary Clinton mustered only 27.5 percent of the statewide vote, she hit north of 75 percent in some of Boise’s urban precincts. Politically, the city might as well be on a different planet from towns that lie a couple of exits away.

And this is true in more than just America’s twee precincts. More than ever, urbanites share a common affiliation, whether they are in Idaho or Massachusetts, whether they’ve built up earthly treasures or scrape by on minimum wage. In presidential elections, votes are tallied by county and grouped by state, but zoom in closer and you see that Democrats cluster like blue inkblots on a mostly red map and that many jurisdictions are sharply divided. In the 2016 election, virtually every large urban center and many small ones — white Boise and majority-black Baltimore, wealthy San Francisco and beaten-down Detroit, sprawling sunwashed megalopoli and shrinking union strongholds — rejected the man who became president, often by yawning margins. The density that is one of the defining characteristics of cities forces encounters that, more and more, seem to strengthen Democratic principles — and separates urban dwellers from their rural cousins.

While cities like New York and Seattle have always been liberal, others have converted much more recently. After World War II, San Francisco was up for grabs, voting Republican in 1952 and 1956, after which its Democratic tilt increased from year to year. Philadelphia was a Republican bastion until 1951, when a new charter combined with a corruption scandal to demolish the political machine. Ward leaders and local bosses switched their allegiances just as middle-class whites were fleeing to the suburbs, leaving the heavily black central city to the party of civil rights.

Columbus, Ohio, saw the light of liberalism only decades later, not because of some grand political realignment but as a by-product of creeping prosperity. A varied economy of largely white-collar employers is now drawing a population that is increasingly young, diverse, well educated, and addicted to pleasant living. “When I first moved there 20 years ago, Columbus was a dull, sleepy midwestern city, a solidly Republican city. It isn’t anymore,” says Steven Conn, a history professor at Miami University in Ohio and the author of Americans Against the City: Anti-Urbanism in the Twentieth Century. “People are interested in better public schools and better urban amenities like bike trails and so on, and the Republican Party is against everything they care about week to week.” In some areas, that process is ongoing. Just this month, in a single congressional district in one of the reddest states, Sedgwick County, the Kansas jurisdiction that includes Wichita, swung to the Democratic underdog in a special election; he was swamped by the surrounding rural vote and lost, but not by much.

Houston’s journey toward liberalism merges these same ideological, demographic, and economic shifts and has transformed the political landscape of conservative and largely rural Texas. A vast majority of Texas’s votes come from just a dozen or so counties; Harris County, which contains Houston, is by far the most populous, with 16 percent of the state’s population, and it’s growing fast. Republican presidential candidates — including two generations of locally based Bushes — won the county handily until Obama squeaked by, twice. In 2016, Clinton took the Houston area by 12 percentage points. That local quasi-landslide could represent a particular distaste for a certain New York real-estate developer, but the larger trend looks epochal. Over the decades, the urbanized area has spread; Houston has even acquired one of those expensive gewgaws of contemporary urban living, the ultimate conservative bugaboo: a new light rail, 23 miles of it. Today, the city’s population is 44 percent Hispanic (and growing) and only 26 percent white (and falling). The demographic train is pulling away from Harris County and leaving the Republican Party behind.

Conn, the historian, sees the liberalizing of cities as an inexorable process: “The combination of density, diversity, and economic dynamism makes people see that they share an interest in large public things,” he says. The Houston Chronicle’s editorial page recently excoriated President Trump’s nationalistic policies using strictly economic logic rather than philosophical concerns. “Our city runs on free trade, oil and gas, and low-cost labor,” the paper pointed out. “But now we have to deal with a president who sees Houston’s boons as a threat. It is like a doctor who misdiagnoses a cold for cancer and recommends a full slate of chemotherapy. The radioactive solution of a border tax, import tariffs, and immigrant roundups … will weaken the economic fundamentals of our Gulf Coast port city.”

There is plenty of irony in the fact that Donald Trump exhibits such antipathy to cities, given that he is a product of the nation’s largest. But it’s worth remembering that despite being a New Yorker, the president has rarely, if ever, experienced urban life. For most of us, living in cities means living close to those who are both like us and not. Even just walking down a city block means having no idea who will cross your path, what they believe, or how they will behave. Strolling is a succession of chance meetings, the vast majority of them superficial. At times, a dense neighborhood can feel like a village, where you bump into friends or revive dormant acquaintances. At other times, it means confronting a vast and entrenched homeless population. Urbanites take this haphazardness for granted. We have the ingrained habit of sharing space, of encountering difference, of swimming in the collective soup.

Trump — like many Americans who duck from house to car to office to mall — rarely experiences an unplanned encounter. He has spent much of his life in gilded rooms, surrounded by people he employs. His idea of transit consists of elevators, limos, helicopters, and private jets. Until he moved into the White House, he hardly set foot in a place he didn’t own. Maybe that’s why he knows so little and appreciates less about his own hometown, why a president who was born and bred in New York City spends his time stoking ancient fears about it. When he started planning Trump Tower in the late 1970s, it was an expression of confidence in the deluxe appeal of midtown Manhattan at a time when a seemingly ungovernable city had bled nearly a million people. Now, when urban crime sits in the eerily low range in many cities, when companies follow their most desirable employees into revitalized downtowns, and when many metropolitan areas are more worried about housing shortages and gentrification than about falling apart, the president has revived a vision of cities suppurating with violence and sin. Once he sold urban real estate to customers who wanted to live there; now he sells fantasies of urban horror to those who prefer to shudder from afar.

Wilkes County, North Carolina, 2016. Photo: George Etheredge/The New York Times/Redux

The Trump administration’s disdain for urban culture has a rich bipartisan pedigree. Thomas Jefferson formed his view of nationhood around a belief that the countryside was not only preferable but morally superior. “I think our governments will remain virtuous for many centuries; as long as they are chiefly agricultural; and this will be as long as there shall be vacant lands in any part of America,” he wrote to James Madison in 1787. “When they get piled upon one another in large cities, as in Europe, they will become corrupt as in Europe.”

In 1904, the original muckraker, Lincoln Steffens, went on a crusade against corruption in Minneapolis, St. Louis, Pittsburgh, Philadelphia, and Chicago. (He considered New York relatively benign.) He, too, intimated that there was something about governing large concentrations of people, about cumulative economic might combined with massed indifference, that nurtured the worst forms of power. Membership in an urban elite, he suggested, was inherently putrid. “There is no essential difference between the pull that gets your wife into society or a favorable review for your book, and that which gets a heeler into office, a thief out of jail, and a rich man’s son on the board of directors of a corporation,” he wrote in The Shame of the Cities. “And it’s all a moral weakness; a weakness right where we think we are strongest.” Debility, opportunism, callousness, shortsightedness, venality — the metropolis concentrated these vices into a noxious stew.

The urban renaissance of the past few decades has opened up a new line of moral attack. The Times columnist Ross Douthat recently argued that large cities are not the tolerant utopias that liberals idealize but black holes of privilege, sucking in resources and jobs. Douthat writes as if Manhattan were the norm: “If [cities] are dynamic, they are also so rich — and so rigidly zoned — that the middle class can’t afford to live there and fewer and fewer kids are born inside their gates. If they are fast-growing it’s often a growth intertwined with subsidies and ‘too big to fail’ protection … We should treat liberal cities the way liberals treat corporate monopolies — not as growth-enhancing assets, but as trusts that concentrate wealth and power and conspire against the public good.” One way past America’s political impasse, he proposes, might be to break up the largest cities and disperse their corporate headquarters and government offices to smaller provincial burgs. The prescription is worth exploring — the Department of Agriculture might fit in nicely in Omaha, say — but his premise is astonishingly wrong. New York City ships far more tax money to Albany and the IRS than it gets back. Many of the federal dollars that do wash into the five boroughs generally pay for projects of regional and national import, like airports, roads, and security. Cities don’t sluice away public funds; they’re engines of the U.S. economy. Just 20 of them generate more than half of the nation’s GDP, a percentage that continues to increase. Big cities grow bigger because they are efficient social organizations, not because they’re subsidized liberal pleasure domes.

Dense places don’t have a monopoly on turpitude, but cities have always faced formidable challenges. The deindustrialization that nourished the Trump campaign ravaged big cities first: At the end of World War II, New York had the world’s busiest port and most productive factories. Three decades later, shipping and manufacturing were moribund and the municipal government could barely pay its bills. Dozens of cities tore down slums and put up public-housing projects — idealistic efforts that often created more problems than they solved. In places like Detroit and Memphis, unemployment, redlining, crack, and gangs left vast urban stretches traumatized and bleak. Segregation persists in many cities and often worsens for two seemingly opposite reasons: Whites trickle away (as in Cleveland) or else they arrive, pushing into poor neighborhoods that longtime residents can no longer afford. In a handful of hyperprosperous cities like San Francisco, manufacturing has hollowed out and tech businesses have moved in, bifurcating the population into poor service workers and affluent creative types. Even the once relentlessly upbeat urbanist Richard Florida has written a contritely depressing book, The New Urban Crisis: How Our Cities Are Increasing Inequality, Deepening Segregation, and Failing the Middle Class — And What We Can Do About It.

But urban areas also teem with activists, nonprofit technocrats, planners, and social-justice fixers who keep rolling out proposals that municipal governments often adopt: pre-K programs, police body cams, running public buses through minority neighborhoods, and so on. Cities all over the world share problems and expertise, using each other as experimental labs: New Delhi converted its buses to natural gas; La Rochelle, France, launched a bike-share program; Milwaukee demolished a downtown freeway — and each of those experiments inspired hundreds of other cities to repeat it. In 2014, Houston, L.A., and Philadelphia announced a joint plan to combat cities’ disproportionate responsibility for climate-change-causing pollution by slashing CO2 emissions, shifting to renewable energy sources, and converting streetlights to LEDs. And New York has massively boosted its affordable-housing program, raised the minimum wage, invested in high-tech manufacturing — a constantly evolving menu of tools to make the city more livable, safe, and affordable.

Some problems have proved intractable: New York’s homelessness epidemic has defied Mayor de Blasio’s expensive attempts to alleviate it. And gun violence persists in parts of Chicago despite a dramatic decrease in crime in many cities. But progressive activists can also point to a deep legacy of success, as anyone who ambles around South Bronx neighborhoods like Melrose can attest. Not so long ago, this was ground zero of hopelessness. When observers remarked that the Bronx of the ’70s seemed like a war zone, they were not merely using a figure of speech. Yet those who looked around back then and saw no future for troubled neighborhoods were guilty of a failure of imagination. Grassroots organizations — like Nos Quedamos & WHEDco (Women’s Housing and Economic Development Corporation) — worked with successive mayoral administrations to clean up, rebuild, and repopulate areas that many had written off as toxic wastelands.

Nevertheless, many conservatives see the city as the degraded outcome of decades of Democratic control. “Cities have become the equivalent of holding cells for the poor and minorities,” writes Peter Collier in the introduction to The New Shame of the Cities, a 2014 screed published by the right-wing David Horowitz Freedom Center. “Everything that’s wrong with America’s cities that can be affected by policy, Democrats are responsible for … America’s urban centers have slid into violence, corruption and savage dysfunction that make the snapshots of despair Lincoln Steffens produced at the beginning of the 20th century seem mild by comparison.” During his campaign, Trump distilled that message into a halfhearted plea for African-American votes: “You’re living in poverty, your schools are no good, you have no jobs, 58 percent of your youth is unemployed — what the hell do you have to lose?”

In turn, urban intellectuals demonize the countryside just as their forebears excoriated the suburbs. “Rural America is the new inner city,” says Conn. “It’s where all these social pathologies collect, and they’re connected to the collapse of rural economies and rural communities. That’s exactly what you saw in North Philadelphia when the plug was pulled.”

The political gulf between city and non-city has deepened even as the physical boundaries between them have blurred. Cities have become more suburbanized and suburbs more citified, pushing the dividing line farther and farther from downtown. These two contrary currents have been in motion at least since the 1940s, when the Metropolitan Life Insurance Company built Stuyvesant Town as a verdant middle-class enclave in the middle of Manhattan, its blocky, high-rise architecture softened by planted courtyards and the absence of cars. More recently, ubiquitous mall brands, an influx of educated young transplants, and a citywide tree-planting spree have given formerly gritty parts of Brooklyn an almost bucolic air.

Oddly, the suburbification of cities has only strengthened their liberal tendencies, and the citification of suburbs is doing the same. Flight’s not white anymore: Urban refugees come in all hues, and they arrive in their cul-de-sacs with a taste for Indian groceries, halal restaurants, and walkable downtowns. Since 2000, the majority of immigrants have dispersed into outlying areas rather than packing into inner-city enclaves. In his campaign speeches, Trump repeatedly conflated “black” and “inner city” neighborhoods, but in fact African-Americans are suburbanizing at a steady clip, turning suburbs blue in the process. Research by urban-studies professor Kyle Walker suggests that as blacks have moved out of central Minneapolis into the inner-ring suburb of Brooklyn Center, that area has become more Democratic.

The project of citifying outlying areas has been helped along by an army of planners, variously grouped under the rubrics new urbanism, smart growth, and sustainable development. In places like Arlington, Virginia, and Kirkland, Washington, developers are rushing to satisfy new suburbanites’ hankering to get out of the car — or not to own a car. In their 2008 book Retrofitting Suburbia, Ellen Dunham-Jones and June Williamson chronicled the transformations of dead malls and vacant big-box stores into “lifestyle centers” and libraries. And the Museum of Modern Art’s 2012 exhibition “Foreclosed: Rehousing the American Dream” asked high-octane teams of architects to imagine how ailing suburbs could be saved. Mostly, they came up with an archipelago of mini-cities.

Conservatives have reacted with predictable fury to urban incursions onto their suburban turf. In 2012, the Republican National Committee struck simultaneously at an assortment of enemies — the United Nations, the environmental movement, public transit, and city folk — with a statement attacking the U.N.’s sustainable-development program. That “destructive and insidious” plan, the RNC announced, undermined “the American way of life of private property ownership, single-family homes, private car ownership and individual travel choices.” Democrats drive cars too, of course, as do the residents of most American cities, but only one side of the political spectrum turns a necessity into a patriotic virtue.

The suburbs are political border zones where attitudes shift from street to street. It would be more accurate to talk of swing neighborhoods than swing states.

If the residents of Trumpland don’t like or understand cities, hard-core urbanites are equally ignorant about the suburbs that surround them. We drive through landscapes branded by 7-Elevens and patterned with single-family houses, and we see only a uniform plague of sprawl. In fact, the suburbs are the political border zones where attitudes shift from street to street. It would be more accurate to talk of swing neighborhoods than swing states. “Living in the suburbs today represents an economic choice without an ideological choice,” says Richardson Dilworth, director of the Center for Public Policy at Drexel University. Where once an ideological barrier sealed off the city from the suburb, the new, fuzzier divide pits cities and inner suburbs against exurban and rural America. You have to drive farther and farther out — and along particular routes — before you hit consistently Republican turf.

Last November, on the Saturday after the presidential election, I drove to the Costco in Teterboro, New Jersey. As I piloted my oversize cart crammed with household cleaner and eight-packs of canned tuna, I scanned my fellow shoppers for clues as to what had happened at the polls. The uniform glare of the warehouse revealed a staggering variety of American life: families and couples of every background, blending English with a dozen different languages. A few basic characteristics united us all: We had cars, storage space, and a sense of thrift. Nearly everyone was buying toilet paper. How, I asked myself, could anyone wander through a discount megastore full of peaceful diversity, buying products shipped in from all over the world, and understand the ethnic grievances that wound through the campaign? I also wondered how many of my fellow Costco members had voted for Donald Trump.

Probably about half, it turns out. A town-by-town map of New Jersey’s election results shows that this particular Costco is strategically placed at the vortex of political views. A few miles west and the map shades from pink to red; it gets gradually bluer closer to the Hudson River. Jersey City went for Clinton 83 percent; Union City, 79; Hoboken, 73. A ten-minute drive west, in Secaucus, Clinton’s support was only 55 percent. The Chicago area had a similarly gradual shift conservative as you move away from the lakefront.

Density makes towns more liberal. So does public transit. A band of dark, Clinton-heavy blue follows the Metra commuter rail line from downtown Chicago south to University Park, where it dead-ends in a field of red. Milwaukee’s bus system extends west to 124th Street and north to the county line, and those borders define political boundaries, too: Beyond the bus routes, the map turns from blue to red, literalizing Wisconsin’s dramatic divide. In the Bay Area, tendrils of blue radiate out along train tracks into the deep-red heartland of the San Joaquin Valley. Interstate 5 runs north-south without disturbing the political landscape, but 40 miles east, Amtrak links Stockton, Modesto, Merced, Fresno, Bakersfield — each one an isolated dab of blue.

It’s not clear what accounts for this political force field that weakens with every mile from City Hall but that’s carried from center to center along transit lines. Do people with strong political views choose to live in like-minded communities, or do the places people choose to live form their opinions about how society should work? Which comes first: real estate or ideology? Either way, the dynamic behaves like an ideological centrifuge, distributing liberals and conservatives in complex but not random patterns.

The growth of urban areas is a self-perpetuating cycle. So long as that’s where the jobs are, workers will move there from all over the world, including from the Republican heartland, exaggerating a population distribution that is already wildly uneven. Mark Abraham, executive director of the Connecticut-based number-crunching organization DataHaven, pointed out in a series of tweets that Los Angeles County (just one core nugget of the L.A. megalopolis) contains more people than do 43 states. If everyone who lived in the nation’s ten most populous counties formed a tug-of-war team, they’d be evenly matched against the 2,167 least populous ones.

Theoretically, the more cities grow, the more states they will swing in a liberal direction. And yet urbanization is a fitful and contradictory process. Some cities are growing while others shrink. Clevelanders move to Sun Belt suburban areas around Orlando, Tampa, Las Vegas, and Phoenix, and it’s not clear whether, when these northern liberals settle in Joe Arpaio territory, they maintain their political affiliations or blend in with the local red.

Conflict between urban and rural areas is a worldwide phenomenon. The Brexit vote shocked Londoners into the realization that they are outnumbered. The right-wing party of Marine Le Pen represents rural France’s revenge on Paris. Tokyo grows while Japan’s population shrinks, and India’s exploding cities are leaving its villages ever poorer, sicker, and less educated.

And yet Trump’s loathing for the American metropolis has a specific nationalistic ferocity that is prompting cities to test their collective power with protests, confrontation, lawsuits, and refusal. If anti-Obama obstructionism was headquartered in the halls of Washington, D.C., and supported by several dozen statehouses, the anti-Trump resistance is playing out on city streets and in hundreds of city halls. From the earliest moments of the administration, protesters packed into downtowns and converged on metropolitan airports, and officials discovered a shared sense of mission. It is now the job of cities to protect immigrants and civil rights, to lead the fight against climate change, to keep America enlaced with a puzzled world. As the federal government threatens to leave urban America in the lurch, cities are confronting that abandonment with a kind of hearty optimism and confidence in their own strength. At a recent forum sponsored by the Center for an Urban Future and NYU’s Wagner Graduate School of Public Service, speaker after speaker pointed out that cities are forced to tackle issues on which Washington can afford to punt. “It’s not that cities are close to the ground; we are the ground,” said Philadelphia’s former mayor Michael Nutter. “We are the incubators of innovation.”

For instance, Urban America has banded together on immigration for a combination of economic and philosophical reasons. The cities with the highest proportions of foreign-born residents, like New York, Miami, San Diego, and Houston, are also among the most economically muscular; those with the smallest are often depressed. That’s circular, of course: Immigrants go to Miami rather than Birmingham, Alabama, because that’s where the jobs are. And those influxes keep the population at a healthy churn, allowing cities to diversify their economies. In 2013, immigrants made up 43 percent of New York’s workforce and generated a third of its output.

It’s not just megalopoli like New York and Houston that need a steady supply of foreign-born workers. The global engineering firm Cummins, Inc., recruits employees from all over the world to work in the small city of Columbus, Indiana, making it an unlikely LGBTQ and immigrant enclave in the middle of Mike Pence territory. And the mayor of Dayton, Ohio — nobody’s idea of a hipster mecca — has made it clear that her city welcomes new foreign-born arrivals, who offset the steady loss of native-born Daytonians, strengthen the economy, and reverse population decline. Not to put too fine a point on it, but immigrants are saving a city that might otherwise spiral into collapse. That immigrant friendliness could have long-term political consequences: Dayton lies in Montgomery County, one of the many largely rural midwestern counties that inched away from the Democratic Party in the 2016 election, going for Trump by less than 2,000 votes and giving him a barely visible margin of 0.7 percent.

These issues have crystallized in the conflict over sanctuary cities. The concept gathered energy as the Obama administration ramped up deportations of undocumented immigrants with criminal records. Trump’s broader, blunter actions have jolted mayors into proclaiming themselves principled defenders of the foreign-born. Many cities forbid their police forces to ask people they stop or arrest about their immigration status. And local law-enforcement agencies often refuse ICE requests to detain anyone who can’t show proof of legal residency. It’s a stand that pits them not only against federal authority but often against their own state government. The mayor of Houston, Sylvester Turner, announced preemptively that the city would refuse to comply with an anti-immigrant bill now working its way through the (Republican-controlled) state assembly: “Regardless of what the legislation may be, the Houston Police Department is not going to profile people. We are not going to be ICE. Period. End of discussion.” Similarly, newly elected Austin sheriff Sally Hernandez issued an eight-minute video explaining when her department would honor Immigration and Customs Enforcement requests to detain people and when it wouldn’t. Texas governor Greg Abbott is not amused. “The country is not called the ‘United States of Municipalities,’ ” he grumbled, by which he seemed to mean that we don’t live in the United Cities of America.

The Trump administration has responded to ornery cities by threatening to withhold federal funds, a position of dubious constitutionality, and to beef up the ranks of ICE, which can bypass local law enforcement and conduct its own raids. Even as the president’s travel ban was getting beaten up in court, ICE agents staged scattered actions, scooping up undocumented immigrants with and without criminal records. Offering no evidence, Attorney General Jeff Sessions has blamed immigrant-friendly cities for an unspecified wave of murders: “Countless Americans would be alive today and countless loved ones would not be grieving today if these policies of sanctuary cities were ended.” He also warned that localities that failed to cooperate with immigration officials would be making a big “mistake.”

The power struggle between urban and nonurban America has gone on since the 18th century and will likely continue for generations. The tension is baked into the Constitution, which tilts the balance of power toward rural states. Thanks to the vagaries of the Electoral College, today’s Wyoming voter has nearly four times the clout in a presidential election of a voter in California, and both states get the same number of senators. That deliberate imbalance is why Trump was able to carry the election while not just dismissing cities but denigrating them.

But writing off large urban conglomerates is unusual for ruling parties. Authoritarian regimes often find that cities test their ability to exert control. When food prices spiked in Tunis and Cairo in 2011, for instance, the concentration of unhappy, hungry crowds quickly flared into revolution. So far, the crowds that have gathered on a regular basis to protest the Trump administration — like the Women’s March that flooded cities all over the country the day after the inauguration — have been peaceful, even joyous. The danger is less that urbanites will start pulling up cobblestones or piling Citi Bikes into barricades than that they will further separate from the red seas that surround them.

Already liberals are deploying formerly Republican positions (and legal precedents handed down by a conservative Supreme Court) to argue in favor of local independence, while conservatives insist on imposing the will of a federal government they claim to despise. It’s a liberal cities’-rights movement as opposed to a conservative call for the rights of states. It seems likely that the cracks dividing cities from not-cities will continue to deepen, like fissures in the Antarctic ice shelf, until there’s nothing left to repair. The more metropolitan liberals resist, protest, strike, and boycott, the more foreign and incomprehensible they will seem to everyone else.

*This article appears in the April 17, 2017, issue of New York Magazine.