Celebratory gunshots rang out. Young men sprinted down the narrow streets of the capital, whooping with excitement. It was Feb. 25, 2012, and Ali Abdullah Saleh, who ruled Yemen for 33 years, had resigned — another autocrat toppled by the Arab Spring.

As other Yemenis excited by the prospect of a new future filled Change Square, Suleiman Habib sat on the steps of his sparse home on the outskirts of the capital. Watching fireworks burst over the city, he contemplated whether his people’s more-than-two-millennia-long history in the country was about to end forever.

A gaunt silversmith in his mid-60s and one of the last members of an ancient community of Jews living in Yemen, Habib was fearful of a future without the autocrat he saw as a guardian. Almost two years after the nation’s rebellion against Saleh, he feels no enthusiasm for his country’s democratic awakening.

“Saleh was a despot. He ran Yemen like a fiefdom, he neglected people and stole natural resources, but as a Jew my family and I were protected by him. Who will do that now that he is gone?” says Habib.

It’s a sentiment that resonates across the Middle East, where massive unrest has shaken governments from Damascus to Tunis but has also unleashed a wave of sectarianism. With Coptic Christians under attack in Egypt and religious and ethnic rifts hardening in Syria’s civil war, the region has become a more dangerous place for minorities. Looming large is the question of how these groups will fit into new social orders, if at all.

Yemeni Jews say they reached south Arabia more than 2,500 years ago, as merchants sent by the legendary King Solomon to trade for gold and silver to adorn his temple in Jerusalem. For centuries they flourished, living in towns and villages alongside Muslims and working as carpenters, masons and silversmiths because they were largely excluded from other professions.

Under the Shia imams who ruled Yemen for most of the past millennium, Jews were classified as dhimmi — non-Muslim citizens who had the right to reside and practice their faith in exchange for paying a tax. But there were pogroms, and Jews were set apart by law. In 1792, senior Muslim clerics ordered synagogues destroyed. By religious decree, Jews were forbidden to wear new or good clothes, were not allowed to bear arms or ride mules, and were forbidden from wearing jewelry or a jambiya, the traditional curved daggers worn by Yemeni men.

During the 1948 war that led to the creation of Israel, anti-Jewish sentiment rose in Yemen and across the Middle East. Rioters killed some 80 Jews in the port city of Aden and plundered most of the Jewish shops in the city. Consequently, 49,000 Yemeni Jews, about two-thirds of the community, were airlifted to Israel between 1948 and 1951 in a secret British and American mission dubbed Operation Magic Carpet.

Today, as Yemen tries to navigate a path toward democracy and a more inclusive political system, the last wave of emigration looks to be under way. In August, the Jewish Agency for Israel, a semigovernmental Israeli organization, helped smuggle 17 Yemeni Jews to Israel. Less than 90 remain.

“Jews who lived their entire lives there and resisted the notion of leaving for a long time are going now. It’s time,” says Misha Galperin, the head of international development for the Jewish Agency, adding that the recent airlift was a “clandestine operation” because Yemen and Israel have no diplomatic ties.

Most of the 20 or so families that remain, including Habib’s, live behind the walls of a government compound for expats near the U.S. embassy in Sana‘a called Tourist City, cut off from the rest of society. The elders never leave. Now and again the younger men venture out to sell jewelry at a nearby market.

Reels of razor wire, soldiers and German shepherds make the entrance look like a prison. Inside it is quiet and leafy. With a playground, two ATMs, a restaurant, pharmacy and a bus to shuttle them around the compound, it has the sleepy feel of a retirement community in Florida.

The Jews, who raise goats and chickens on plots of land next to the homes of Russian oil barons and aid workers, rarely leave the compound. Instead they rely on a monthly stipend for food and rent provided by the government.

In a modest apartment filled with smoke, a vacant Habib and several other Jewish elders rest on cushions, smoking shisha pipes and chewing khat. A portrait of Saleh dominates one wall. A wily tank commander turned politician, Saleh was well known for courting the Jewish community. He appeared frequently on state TV with the community’s rabbi, and once delivered legs of lamb at Passover to the families in Tourist City. His critics dismissed such gestures as window dressing for his dictatorial rule.

It was Saleh who, in 2009, enabled Habib and his family to flee to the capital after their house was bombed in Saadah — a northern province controlled by a Shi‘ite group called the Houthis, who count “Death to Israel, damn the Jews” among their slogans.

Life in the compound, while often mundane, allows Habib and the other Jews who fled other parts of Yemen a large degree of religious freedom. The women, who had worn veils in public in deference to their Muslim neighbors, walk between the houses in bright green dresses, carrying pots of lamb stew, or choula, and chatting loudly, their faces uncovered. The men, many in long white galabiya with their side curls and kippah in full view, sit in the compound’s synagogue reciting verses from the Torah, a practice that was previously confined to their homes.

But rising lawlessness in the aftermath of Saleh’s departure, and the failure to include Jews in an ongoing national dialogue, fuels a belief among the Jews that they are being abandoned by the transitional government. Last year the official in charge of Tourist City cut off food rations for eight months, and one of the residents, Aaron Zindani, was stabbed to death by a street vendor while at a nearby market with his children.

At the same time, anti-Jewish sentiment in Yemen is anything but universal. Yemenis, when asked, often refer to the Jews as their “brothers.” Many mourn the departure of their country’s oldest religious minority as a loss to Yemen and its once multiracial identity.

“They are Yemenis,” says Ashwaq Aljobi, who works at the Sawaa Organization for Anti-Discrimination, a nongovernmental organization that advocates for Yemen’s Jews and other marginalized peoples. “If they want to travel, it’s O.K. But if they stay here, it is still their country.”

Habib is torn. Yemen is his homeland, he says, and he plans to die here. But his family members are leaving one by one. His eldest son Ibrahim, who tucks his side curls under a Yankees cap when he leaves the compound to avoid attracting attention, says he plans to join his cousins in Tel Aviv later this year.

“Living in a state of exile in your own country … that’s no life.” says Ibrahim, gloomily. “It’s a sad thing [because] Yemen will always be part of me, but I can no longer be part of it.”