London is stuffed with landmarks — including the Gherkin building, above — but also with 8.7 inhabitants representing 270 nationalities.

London may be the capital of the world. You can argue for New York, but London has a case. Modern London is the metropolis that globalization created. Walk the streets of Holborn, ride an escalator down to the Tube and listen to the languages in the air. Italian mingles with Hindi, or Mandarin, or Spanish, or Portuguese. Walk through the City, the financial district, and listen to the plumbing system of international capitalism. London is banker to the planet.

Scenes from the crossroad of the world: St. Pancras International, where passengers can catch a train to Paris. Sergey Ponomarev for The New York Times

London is ancient yet new. It is as much city-state as city, with a culture and economy that circulate the world. London manages to be Los Angeles, Washington and New York wrapped into one. Imagine if one American city were home to Hollywood, the White House, Madison Avenue, Wall Street and Broadway. London is sort of that.

A vigil for the victims of the terrorist attack last month. Sergey Ponomarev for The New York Times

Modern London thrives on the idea that one city can be a global melting pot, a global trading house, a global media machine and a place where everyone tolerates everyone else, mostly. The thought is that being connected to the rest of the world is something to celebrate. But what happens to London when that idea unexpectedly falls away?

Visitors reflected in the glass of a viewing platform at the top of the Shard, Western Europe’s tallest building. Sergey Ponomarev for The New York Times

— St. Pancras International rail station, a wonder of Victorian architecture resurrected for the 21st century, opened 10 years ago as the embodiment of a particular notion: that Britain is part of something bigger than itself and that belonging to a fellowship of nations is as easy and natural as stepping onto a train.

It was both shocking and thrilling, at first, that you could catch a Eurostar from a platform in London, slide under the English Channel, hurtle through the French countryside and less than three hours later pull into the Gare du Nord in Paris. To ride the Eurostar was to marvel that the capitals — London so prosaic and straightforward, Paris so romantic and mysterious, the two with their long history of rivalry and discord — were part of the same larger enterprise.

Eurostar symbolized an era in which London seemed to be inevitably rushing toward Europe, too. At least that was the idea until now, and the beginning of the process known as Brexit. The trains are still running, but the era that created modern London appears to be over.

Losing London

This article is part of a series examining whether “Brexit” will sink a great global city.

“We’ve made a horrible statement to the rest of the world, and it’s very sad,” said Martin Eden, a publisher waiting to catch the Eurostar to Paris the other day, to celebrate his 43rd birthday. “We should be moving together,” he said of Europe, “instead of moving apart.”

I met Mr. Eden as I wandered around St. Pancras at the moment Britain officially filed for divorce from the European Union. It was lunchtime on March 29, Brexit Day, as you might call it, when Britain delivered a letter to Brussels and opened two years of negotiations over the rules of disengagement.

But as Britain tries to bid farewell to its now-estranged partner of 44 years, London faces a different sort of challenge: how a great global city whose residents voted overwhelmingly against Brexit in last summer’s referendum should adjust to an uncertain future governed by principles that feel antithetical to its very being. Brexit has divided Britain from Europe but also divided Britain from itself, with London on one side and much of England on the other (Scotland and Northern Ireland, which also voted to remain, are another story).

To many people in the capital, the vote last year feels like a rejection not just of Europe but also of the values embodied by London, perhaps the world’s most vibrantly and exuberantly cosmopolitan city: values like openness, tolerance, internationalism and the sense that it is better to look outward than to gaze inward. Even as a sense of melancholy seemed to descend on St. Pancras when I walked around the other day, much of the rest of Britain was celebrating.

“A Magnificent Moment,” The Daily Telegraph announced on its front page the next morning; “Dover and Out,” said The Sun, referring to the White Cliffs of Dover. But even as much of the country has spoken darkly of the influx of immigrants, the erosion of British values and the siphoning of resources by Europe, London has remained about as heterogeneous and open-minded a place as you could imagine, especially for a 2,000-ish-year-old metropolis.

Here are Britain’s richest people and many of its poorest, living side by side in relative peace. London is stuffed with British landmarks — Big Ben, Buckingham Palace, St. Paul’s Cathedral — but also with people comprising 270 nationalities, 8.7 million inhabitants in all.

Brexit has thrown into disarray this great experiment in tolerance. Nobody can predict what the city will look like in 10, 20 or 30 years. If spontaneous travel between Europe and Britain no longer seems so simple, neither does the easy exchange of people, capital, jobs, businesses and languages. Perhaps more significant, it is no longer clear that these are meant to be admirable things, here or anywhere.

“London is a weird place at the moment,” said the writer Nikesh Shukla, whose book “The Good Immigrant” is made up of essays by nonwhite Britons about a country from which they feel increasingly alienated. He lives in Bristol now but grew up in London, and the city, he says, “feels like a uniquely encapsulated version of what Britain means to me.”

“The government says it’s trying to get the country back, but in the process it’s losing the heart of its people in London,” Mr. Shukla said in a telephone interview. “People feel uneasy because there are a lot of futures at stake. These are people who live in the city who contribute to society, who have families, social structures and financial commitments, whose futures are now in doubt.”

The Millennium Bridge, a pedestrian footbridge over the Thames.

What happens next? No one really knows. Pro-Brexit Britons are happy, of course, even if headaches will follow. This is probably the noisiest and most complicated divorce in modern European history. London is still busy, the Tube is still packed and the pubs are still full. But it is a weird moment. The certainties that sustained a great city are no longer certain.

A woman at her shop at Nomadic Community Gardens. Sergey Ponomarev for The New York Times

“You can’t live in an island and call it your oasis,” said Shirley Watkins, 83, who was waiting at St. Pancras the other day for a train to France. “I think it’s sad that we’re pulling out.”

A crowd waited for the start of a boat race on a bank of the Thames. Sergey Ponomarev for The New York Times

People have complicated feelings about what might happen to London. “A lot of people my age are not happy — are they going to have to move back to France?” said Antoine Nauleau, a dual French-American citizen who works here for now. But he said he can see another side to the argument in the country in general. “It seems that the U.K. is losing a lot of support, but also kind of defining itself.”

Prayer at the Brick Lane Mosque, a former church that was transformed in 1976 to accommodate Bangladeshi immigrants. Sergey Ponomarev for The New York Times

I lived in London for more than 15 years, returning home to New York in 2013. The city changed a great deal in that time, and the city I left felt markedly different from the one I found when I arrived. It felt more open, more international, more enthusiastic, more exciting. The food got better, and places stayed open later. My neighbors seemed to come from a United Nations’ worth of countries, our differences somehow erased because we all shared them.

The city also grew a lot richer, which was not necessarily a good thing: The center of town became all but unaffordable. Russian oligarchs and other members of the world’s ultrarich elite dug up the streets to build subterranean complexes filled with swimming pools and parking garages for homes they planned to live in only a couple of weeks each year.

Europe, which had seemed like a distant concept, suddenly seemed right there on the doorstep. Crowds of French people and then Poles and Spaniards and, later and more contentiously, Romanians moved in. Any time you went to an art gallery or a movie, you saw how British culture was benefiting from European financing. The rise of laughably cheap no-frills airlines made air travel to Europe almost easier than train travel. Tony Blair, prime minister for much of that time, liked to take his vacations in places like Tuscany, in Italy.

I’ve been back a number of times since I left, but it was during two visits in the past few months that I encountered something different: fear for the future and a questioning by many non-Britons of whether they even belong here anymore.

“Even for those that haven’t talked about leaving, there’s something fundamentally ruptured in their relationship with the country,” said Ian Dunt, editor of the website Politics.co.uk. “When people say they’re very anti-immigration, no one thinks that’s directed at German architects or French lawyers. But even those people are beginning to feel that the country is becoming cold and meanspirited and indifferent to their presence, if not openly hostile toward them.”

London is big and unwieldy and constantly changing. It resists easy definition.

Here, despite the anti-Muslim, anti-immigrant sentiments that helped fuel the Brexit vote, is London’s first Muslim mayor, Sadiq Khan, whose parents, a bus driver and a seamstress, came from Pakistan. Here are international financiers and playboys, Eurocrats and Eurotrash, as well as economic migrants from Spain and Portugal and other depressed European countries crowding into tiny flats on the edges of town and taking jobs in cafes, on construction sites, in hotels.

“In London I never feel like an outsider, because everyone’s an outsider,” said Paolo Martini, 32, a hairdresser I met in Kentish Town who comes from Brazil and has a Polish wife and a British (by virtue of her birth) daughter. He has lived here for more than a decade; who knows what Brexit will mean for his family?

Part of what makes London different is how closely it all knits together, people from different economic backgrounds as much as different ethnic ones. Every borough has its grand houses and its public housing projects, sometimes right around the corner from one another.

“It’s not just me and you and rich and poor,” said Dara Djarian, 25, a real estate agent in Kilburn whose parents are French and Iranian. He compared the jumbled-up neighborhoods of London with the more uniform banlieues at the periphery of Paris, centers mostly for Arab immigrants. “Everyone’s all mixed up here.”

I looked down Kilburn High Road from his office and saw what he meant. A Polish delicatessen was next to an Italian restaurant across the street from a traditional London pub beside a Halal butcher shop. There was the Shah furniture store, a classic fish-and-chips place, a ladies-only hairdresser, a luxury bathroom-fixture store, some fancy coffee shops and the highbrow Tricycle Cinema, with a program that appeals to hipsters and cineastes.

“The one thing we don’t actually see a lot of here is English people,” Mr. Djarian said. “They’ve moved out to the countryside, or to the suburbs.”

Back in February, a political rally drew a crowd not far from Hyde Park. What was unusual — or it would have been unusual, in a different city — is that the candidate featured at the rally, Emmanuel Macron, was running for president of France. Mr. Macron had come to London because something around 270,000 French people live here, enough to form a city unto themselves. (Many are concentrated in a posh neighborhood in South Kensington known locally, and not very kindly, as Frog Alley.)

The Rupert Murdoch-owned Times of London, which is not a fan of the European Union or, for that matter, of France, sent the political columnist Patrick Kidd to write about the event.

He could not tell his readers exactly what Mr. Macron said, however, because, as he boasted in the article, he does not really speak French, although he studied it in school. But why should he make an effort, seemed to be the idea, when it is so easy to ridicule the French for being French, and when to be English is to feel superior to your neighbors?

“Mr. Macron did not ask for directions to la gare once,” Mr. Kidd wrote, alluding to his French lessons in school. “He didn’t even say ‘zut’ or ‘bof.’ One wondered if he was French at all.”

Mr. Kidd’s hauteur isn’t surprising, given that Mr. Murdoch’s papers and the rest of the country’s right-leaning news media have spent decades nurturing an ancient anti-Europe narrative long reflected in the Conservative Party’s Euroskeptic wing. If London, or at least much of London, has welcomed or tolerated all the changes, many people around Britain, particularly from older generations, have lamented that they no longer recognize the country of their childhoods.

The populist tabloids stoked that anxiety and resentment, often veiling it in easy stereotypes and portraying anyone who objected to the coverage as tediously “politically correct.” They used crude World War II metaphors when England played Germany in soccer. They mocked Europe as a place of humorless Krauts and garlic-eating Frogs, deriding the European Union as an impenetrable, out-of-control bureaucracy sucking up British money and imposing risible, onerous laws on an unwitting populace. Multiculturalism, the zero-sum argument went, was causing Britain to lose sight of what it was meant to be.

“We fly the British flag, not these awful things you are putting on tails,” former Prime Minister Margaret Thatcher snapped during the Conservative Party Conference in 1997, upon seeing a miniature British Airways 747 whose tail was decorated with an image from a foreign country, part of a short-lived effort to celebrate the airline’s global reach. After unearthing a handkerchief from her handbag, she slapped it across the back of the plane. (“For Christ’s sake, can’t we have British designs?” her husband, Denis, added.)

It is an irony of history that it was Mrs. Thatcher who may have given birth to modern London, when her government deregulated the financial markets in 1985 in the so-called Big Bang, paving the way for the city’s rise as a global financial behemoth. Nine years later, the Channel Tunnel opened, a victory for common sense (its detractors had argued, among other things, that rabid Continental dogs might use it to sneak into Britain) and a feat of engineering that seemed to defy the physical and metaphorical laws of the English Channel itself.

Tony Blair’s election as prime minister, in 1997, ended 18 years of Tory rule and ushered in an era when belonging to Europe felt like something verging on cool. Speaking a foreign language was suddenly, briefly, O.K. And then, in 2012, London hosted the Summer Olympics, advertising itself as a city for the world and proving how smoothly and joyfully this polyglot place worked when it put its mind to something, and how unusually well the people who lived here got along.

“People here are coming in from every single nation and just walking around so casually,” Cristina Barba, who is 23 and Spanish, told me, “and it all feels very natural.”

She pays $750 a month for a room in a house on the edges of the city (affordable housing is unattainable closer to the center) with seven roommates who include recent arrivals from Italy and Romania. She works on Brick Lane, home to a large Bangladeshi population, in Absence of Colour, a shop selling expensive monochromatic clothing from an Icelandic designer.

“In Spain you feel like there’s a division between Spaniards and people who look differently,” she said. “But here, there is no division. Everyone just coexists.”

Fujiko Nakaya’s fog installation outside the Tate Modern museum.

Is London lost? Not in the slightest, say those who voted for Britain to leave the European Union. They say that London is reclaimed.

A waiter at the restaurant at the top of the Gherkin building. Sergey Ponomarev for The New York Times

It is strange, the bustle. Construction crews are still putting up buildings, monuments to London’s future, as if nothing has changed. But you can hear faint footsteps, too. Banks, investment firms and other companies are making contingency plans to move elsewhere, if necessary. What then?

WE Day UK, an event last month encouraging young people to think about social issues locally and worldwide. Sergey Ponomarev for The New York Times

How do you define London? You don’t, really. “It’s an accordion breathing in and out,” the Canadian author Craig Taylor wrote in “Londoners,” his portrait of the city, describing its ever-shifting population.

Karan Chanana, the chairman and CEO of Amira Nature Foods, second from left, spoke with guests at his home in the Belgravia neighborhood of London. Sergey Ponomarev for The New York Times

At the corner of Brick Lane and Fournier Street, down the block from a row of multimillion-dollar Georgian townhouses, sits the Brick Lane Mosque, a sprawling brick building that is a palimpsest of London in all its practicality.

Built in 1743 as a Protestant church by French Huguenots fleeing religious persecution, it became a Methodist chapel in 1819 and then, in the late 19th century, a synagogue for Jews fleeing a different sort of persecution in a different part of Europe. Finally, in 1976, it was transformed into a mosque to accommodate the newest wave of immigrants, from Bangladesh. No one seems to think there is anything strange about any of that.

At the same time, no one is claiming that London is a utopia. Racism bubbles up, and so do the politics of race. Two years ago, the Bangladeshi-born mayor of the borough of Tower Hamlets was forced out of office after a court found that his campaign had committed election fraud in a number of ways. It was an ugly moment, awash in accusations (and denials) of racism. But people keep chugging along.

“London seems to work, whether by accident or design,” said John Biggs, who took over as borough mayor afterward. Tower Hamlets encompasses not only Brick Lane but also luxury building complexes and some of the poorest housing estates in the country, so he has a lot of different constituencies to contend with. “We work because we’re a pretty tolerant bunch and we knock along together.”

Like the Brick Lane Mosque, London is facing another incarnation, if an uncertain one. The terrorist attack in March became a Rorschach test of Britain’s views not only on the causes of terrorism but on the city itself. Led by Mr. Khan, the city’s mayor, many in London spoke of the diversity of the victims, from many different countries, and said it was wrong to vilify an entire religion for the actions of a Muslim extremist.

Yet in The Daily Mail, the columnist Katie Hopkins wrote that London’s reaction to the March attack only emphasized the chasm between the capital and the rest of the country.

London, she wrote, is “a city of ghettos behind a thin veneer of civility kept polished by a Muslim mayor whose greatest validation is his father’s old job.” Far from getting along, she said, people hate one another.

Later, on Fox News, Ms. Hopkins broadened her idea of division, placing Brexit in the context of a worldwide pro-nationalist, anti-immigration movement extending straight across the Atlantic. London is “Obama on steroids,” she said; the rest of Britain is “essentially Trumptown, where I belong.”

It is strange to me that some Britons who live outside London seem to mistrust and feel alienated from it, given how essential, and central, the city is to the country and how much people like it when they visit. But the things London is proud of also make it an easy target. In 2012, Theresa May, then the anti-Brexit home secretary and now the pro-Brexit prime minister, said that diversity of language in the capital was helping rip apart the nation.

You only have to look at London, where almost half of all primary school children speak English as a second language, to see the challenges we now face as a country,” she said. “This isn’t fair to anyone: How can people build relationships with their neighbors if they can’t even speak the same language?”

The rift between what she said and what Londoners think shows why London is struggling so much right now.

“The idea is that we’re all who we are, and we’re all in it together,” said Victoria Prescott, who teaches English and film studies at the Deptford Green School in Lewisham. The students speak 40 different languages at home but acclimate quickly, she said, through immersion courses in English.

The school emphasizes strength in diversity, and to visit it during the morning recess is to see a playground full of students of different colors and cultures all intermingling as if their differences did not matter. But of course it’s only part of the story. Rebecca Cummings, Deptford Green’s deputy head teacher, mentioned one of her neighbors, an older Brexit supporter bitter at the very things the school celebrates.

“She’d say, ‘I’m sitting in the doctor’s surgery waiting forever next to a Somali immigrant with four kids,’” Ms. Cummings said. “That’s London, too.”

Those feelings are now taking root in the city. Pro-Brexit views are hardening, and many immigrants — rich as well as poor — are wondering if there is any point in staying. What London will look like then is anybody’s guess.

“My main concern is that when the E.U. migrants are kicked out, and the students are kicked out, and all the banks that use London as a hub leave because they are no longer part of the E.U., who’s going to be left?” said Mr. Shukla, the author. “It’ll just be full of tourists who have come to see the queen, and Theresa May.”

Back at St. Pancras last month, nothing official happened to commemorate the moment the prime minister put Brexit into motion. The trains to Paris did not stop running. Nobody’s passport was rescinded at the gate. But in the station concourse you could hear piano music, courtesy of a program in which pianos are installed in public places for anyone to play.

Standing by the piano, Julie Walker and her husband, Simon, said they had chosen a piece of music that would express their joy that Britain was doing the Christian thing and, as they saw it, “cutting all the ties” to an outside world that threatens British self-determination. The song they requested from the pianist, Stewart Yeff, was Leonard Cohen’s “Hallelujah.”

It seemed apt, because it sounds like a song of celebration, but it is really one of mourning.

A couple in their boat at a canal in Islington. Sergey Ponomarev for The New York Times
Correction: April 20, 2017

An article on April 11 about London in the aftermath of the March 22 terror attack described incorrectly a point Katie Hopkins made in a column in the Daily Mail. She wrote that London’s reaction to the attack emphasized the chasm between the capital and the rest of the country; she did not refer to “bombings.”