In an unnamed, war-ravaged city in the Muslim world, two young lovers face a wrenching choice. They can stay in their barricaded apartment as their country descends into sectarian bloodshed and chaos, or entrust their lives and fortunes to a human smuggler who promises to spirit them to safety through a magic portal in an abandoned dentist’s office. The couple choose the mysterious doorway and are instantly transported to a Greek island, where they find themselves among hundreds of other desperate refugees.

With its surreal premise, “Exit West,” an acclaimed new novel by Mohsin Hamid, might feel hallucinatory and distant had it arrived at a different moment. Instead, the novel — which fuses magical realism with a harrowingly vivid story of global migration and displacement — feels ominously relevant.

Mr. Hamid, a cultural chameleon and polyglot who was born in Pakistan and spent more than half his life in the United States and London, didn’t intend to write a dystopian parable about the current refugee crisis. When he began working on “Exit West” four years ago, he started with an abstract idea: a global network of passageways that circumvent borders, allowing migrants to immediately cross oceans and continents and erasing the already porous barriers between nations and cultures.

“The idea of these doors, which I feel already exist, unlocked the form of this novel,” Mr. Hamid, 45, said in a Skype interview from his home in Lahore, Pakistan. “I wanted to write a very large book about the entire world on a very small scale, so I needed to find some way of covering a lot of ground.”

Mr. Hamid’s literary profile has been growing ever since he dazzled critics with his 2000 debut novel, “Moth Smoke,” which explored the lives of hard-partying Pakistani youth and was a finalist for the PEN/Hemingway Award. Since then, his three novels have collectively sold a million copies and been translated into 35 languages.

But “Exit West” is likely to draw a much broader audience, and seems poised to become one of this year’s most significant literary works. To meet demand from booksellers, Mr. Hamid’s publisher, Riverhead, had already ordered four printings before the book’s release on Tuesday. Prominent novelists like Zadie Smith, Michael Chabon, Joyce Carol Oates and Kiran Desai have praised the novel as an urgent and essential story, particularly at a moment when immigrants and Muslims have been demonized.

Mr. Hamid, who lived in the United States for 17 years and describes himself as “culturally and emotionally at least half American,” said the last few months have left him frightened and depressed. He wonders whether he will still feel welcome in an America that appears increasingly hostile to foreigners and Muslims. His native country, where he is raising his two young children, has suffered a wave of terrorist attacks by the Islamic State and the Taliban. The world seems to be veering toward the upheaval and entrenched polarization that Mr. Hamid envisioned in the novel.

He never imagined “Exit West” would become so grimly prescient, with the crisis in Syria displacing millions, and nationalist movements gaining ground in the West. He started writing the story long before rising nativist sentiment led to ‘Brexit’ and Donald J. Trump signed executive orders targeting illegal immigrants and barring refugees from entering the country.

“The basic impulse, this growing need for so many people to move because of political calamity and environmental catastrophe, and the rise of nativism and tribalism — those things were quite clearly happening,” he said. “While I hadn’t imagined we’d be where we are now, I guess I’m not surprised.”

But while “Exit West” seems like a dark reflection of our tumultuous times, Mr. Hamid said the novel grew out of a hopeful impulse.
“What if we look at a very difficult future — can we still find hope and beauty and love and things that we want?” he said. “For me, this is not a novel about dystopia; actually it’s about looking for signs of hope and optimism in the future.”

The novel represents bold new territory for Mr. Hamid, whose earlier works, including “The Reluctant Fundamentalist” and “How to Get Filthy Rich in Rising Asia,” were formally innovative and experimental but firmly grounded in reality. “I’ve tried to abide by the laws of physics up until now,” he said.

He drew inspiration from Jorge Luis Borges, and from children’s literature, one of his favorite genres. He grew up devouring books by J .R. R. Tolkien and C. S. Lewis, and lately has been reading Harry Potter to his 7-year-old daughter. The spare prose in “Exit West” feels almost biblical at times. The magic doors give the story a mythical sweep, as the refugee couple, Nadia and Saeed, escape to Mykonos, then London, then finally the Bay Area, encountering angry nationalist mobs but also benefiting from the unexpected generosity of strangers.

Mr. Chabon said that the surreal elements of the novel allowed Mr. Hamid to write about the refugee experience in ways that “few writers would have the courage or chutzpah to get to.”

“What makes this book special is that it takes on a subject that a lot of readers are going to wish they could avert their eyes from,” he said. “Magical realism is about getting you to look at something with fresh eyes and see something marvelous in the everyday, and there’s something radical about treating the refugee experience as something with the potential to be marvelous.”

Like his protagonists, Mr. Hamid has spent much of his life feeling displaced, rootless and alienated. “Grappling with movement, and the wrenching and painful nature of that, has been very central to my life,” he said.

Born in Lahore in 1971, Mr. Hamid moved at age 3 to Northern California, where his father was studying for a Ph.D. at Stanford. A chatty child, he suddenly found himself cut off from language, unable to communicate with other children. He assimilated, only to be uprooted again at 9, when his family returned to Pakistan. By then, he had forgotten how to speak Urdu, his first language.

“When I was younger I used to imagine I was some kind of a freak, I’m not really anything,” he said. “I became a very good chameleon.”
At 18, he returned to the United States to attend Princeton, where he took writing workshops with Ms. Oates and Toni Morrison. Ms. Oates recalled him as “quietly well spoken, though forceful in his critiques of others’ work.” He later went to Harvard Law School, and continued to write fiction, working on a draft of “Moth Smoke.”

He worked as a consultant at McKinsey & Company in New York, and convinced the company to give him three to four months off a year to write. He later moved to London, where he met his wife, a classically trained singer and musician who is also from Lahore. After the birth of their daughter, Mr. Hamid felt a pang of homesickness, and convinced his wife to move back to Lahore to be near their parents. (He is a dual citizen of Pakistan and Britain.)

“I remember him saying, ‘I have to go back, it’s a waste of happiness to be away from them,’” said the filmmaker Mira Nair, who directed a film adaptation of “The Reluctant Fundamentalist.”

Mr. Hamid has lived in Lahore for the past seven years. He writes while his two children are at school — pacing around his office and reading passages out loud — and works as a consultant for the branding agency Wolff Olins. His wife runs a restaurant.

He’s deeply attached to Lahore. But Mr. Hamid feels conflicted about whether he belongs there. “The life of a writer is more fraught here than it might be in other places,” he said.

Sometimes, he considers leaving again, but worries about the emotional toll on his family.

“It’s not so easy to pick up and leave,” he said. “As is the case in the novel, leaving home is an emotionally violent act.”