Refugee stories often focus on transit, for obvious reasons. Children travel thousands of miles unaccompanied, hiding in train stations and surviving on wild fruit; men are beaten, jailed, and swindled just for the chance to make it on a boat that, if it doesn’t capsize and kill them, will allow them to try their luck in other dangerous seas. But in his new novel, “Exit West,” Mohsin Hamid, the author of “The Reluctant Fundamentalist” and “How to Get Filthy Rich in Rising Asia,” tells a story about migration in which the refugee’s journey is compressed into an instant. (An excerpt from the novel ran in this magazine.) In the world of “Exit West,” migration doesn’t involve rubber rafts or bloodied feet but, rather, “doors that could take you elsewhere, often to places far away.”

When the novel opens, rumors of those doors have started circulating in a nameless, besieged country, where Saeed and Nadia, the book’s protagonists, live. They reside, at first, in an ordinary world. “In a city swollen by refugees but still mostly at peace, or at least not yet openly at war, a young man met a young woman in a classroom and did not speak to her,” the book begins. The novel’s sentences tend toward the long and orotund: “It might seem odd that in cities teetering at the edge of the abyss young people still go to class—in this case an evening class on corporate identity and product branding—but that is the way of things, with cities as with life, for one moment we are puttering about our errands as usual and the next we are dying, and our eternally impending ending does not put a stop to our transient beginnings and middles until the instant when it does.” That last phrase is a statement of purpose for both migration and romance. This is a love story, too.

Saaed and Nadia fall for each other slowly, and then all of a sudden. War speeds up their courtship, the way it seems to hasten everything; on the eroding façade of Saeed’s building, the rocket fire “accelerated time itself, a day’s toll outpacing that of a decade.” When the pair first speak about foreign places, on a secretive date at a Chinese restaurant, they imagine taking vacations to Cuba, or Chile, to deserts with “stars like a splash of milk in the sky.” Nadia wears a full-length black robe, “so men don’t fuck with me,” she explains to Saeed, surprising him. She drops another black robe from her window to him, so that he can pass as her sister and enter her apartment. They smoke joints on their dates and text each other during work; one day, they do mushrooms that Nadia orders over the Internet. Meanwhile, “a group of militants was taking over the city’s stock exchange.” After Internet and cell-phone service abruptly vanish, there’s a run in the city on supplies and cash. Saeed comes to Nadia’s apartment with kerosene, matches, candles, and chlorine tablets. “I couldn’t find flowers,” he tells her.

Hamid draws enchantment from abstraction, in the style of a fairy tale, and his narrative vantage point shifts through time and space with a godlike equanimity. In one paragraph, he describes helicopters containing militant soldiers that “fanned out above the city in the reddening dusk . . . chopping, chopping through the heavens. Saeed watched them with his parents from their balcony. Nadia watched them from her rooftop, alone. Through an open door, a young soldier looked down upon their city. . . . The din around him was incredible, and his belly lurched as he swerved.” Hamid, through this roaming narration, gently diminishes Saeed and Nadia, freeing them from the burden of speaking for the millions who share their condition. They seem like the focal point of “Exit West,” rather than its center, even though they’re the only characters who are given names.

When the city reaches emergency conditions—raids, lockdowns, windows shattered by bullets—Saeed and Nadia seek out the mystical doors. An agent who speaks in whispers, like “a poet or a psychopath,” guides them. “They knew there was a possibility this was the final afternoon of their lives,” Hamid writes. They squeeze themselves through darkness and arrive in Greece, where they find a camp of refugees whose skin tones range from “dark chocolate to milky tea.” Safe at last, they witness fatigue and bitterness in each other for the first time. (I kept thinking about how, in a different sort of novel, these glimpses might provide the impetus for the entire book.) They learn that the doors have become a global system of exit and entry. The “doors out, which is to say the doors to richer destinations, were heavily guarded, but the doors in, the doors from poorer places, were mostly left unsecured.”

Throughout Saeed and Nadia’s story, Hamid intersperses vignettes of magic-realist migration, in which the circumstances and desires that govern the outcome of each crossing are as unpredictable as the trickster doors themselves. An old man from Brazil crosses to Amsterdam, meets another old man, and wordlessly falls in love. While contemplating suicide, a man in England comes across a portal to Namibia, where he remakes his life. A man sees two Filipino girls emerge in Tokyo, and follows them, “fingering the metal in his pocket as he went.” When refugees emerge from doors in San Diego, an elderly veteran asks the police if he can be of assistance; they ask him to leave, and the veteran realizes that he, like the migrants, doesn’t have anywhere to go.

There is, in “Exit West,” constant underlying movement, and a sense that intrinsic laws of moral physics are at work. In a recent interview, Hamid noted that the current political paralysis in America and Europe could be attributed, at least partially, to our denial of the reality of mass migration. “The more that people who are economically freezing and precarious become aware of places where people are economically warmer and more safe, the more they want to move,” he said, adding, “We need to figure out how to build a vision for this coming reality that isn’t a disaster, that is humane and even inspiring.” In “Exit West,” Hamid rewrites the world as a place thoroughly, gorgeously, and permanently overrun by refugees and migrants, its boundaries reconfigured so that “the only divisions that mattered now were between those who sought the right of passage and those who would deny them passage.” He doesn’t flinch from the mess and anger that come from redistribution and accommodation—but, still, he depicts the world as resolutely beautiful and, at its core, unchanged.

The novel feels immediately canonical, so firm and unerring is Hamid’s understanding of our time and its most pressing questions. Whom are we prepared to leave behind in our own pursuit of happiness? Whom are we able to care for, whom are we willing to care for, and why are our answers to those questions so rarely the same? At one point, Saeed points out to Nadia that millions of refugees previously came to their own native country, “when there were wars nearby.” Nadia replies, “That was different. Our country was poor. We didn’t feel we had as much to lose.” Comfort, she knows, can anesthetize one against concern for others. When a door leads Nadia to a beautiful house with a fine bathroom, the towels are “so plush and fine that when she emerged she felt like a princess using them, or at least like the daughter of a dictator who was willing to kill without mercy in order for his children to pamper themselves with cotton such as this.” Hamid exempts no one from the cruelty that shadows contemporary life. At the end of a long sentence, just before Saeed and Nadia leave their home country, he writes that “when we migrate, we murder from our lives those we leave behind.”