When the domes of Edirne's abandoned Great Synagogue caved in, Rifat Mitrani, the town's last Jew, knew it spelled the end of nearly two millennia of Jewish heritage in this Turkish town.

As a boy, Mitrani studied Hebrew in the synagogue's gardens and, in the 1970s, dispatched its Torah to Istanbul after the community shrank to just three families. In 1975, he unlocked its doors and swept away the cobwebs to marry his wife Sara.

"Only I am left. It happens slowly, becoming the last one," said Mitrani, 65,whose family fled here more than 500 years ago.

Now a five-year, $2.5 million government project has restored the synagogue's lead-clad domes and resplendent interior ahead of its Thursday re-opening, the first temple to open in Turkey in two generations, but one without worshippers.

It is part of a relaxation of curbs on religious minorities ushered in during President Tayyip Erdogan's 12 years in power.

Yet it coincides with a spike in anti-Semitism in predominantly Muslim Turkey and a wave of Jews moving away, say members of the aging community, which has shrunk by more than a third in the last quarter century.

The increase, observers say, is linked to anti-Israel sentiment which reached a crescendo during Israel's Gaza offensive in July. Erdogan compared Israel's assault on Palestinians to "genocide" and "Hitler's barbarism."

He drew distinctions between Israel and Turkish Jews, yet his words helped stoke outrage, and local Jews were threatened by public figures and pro-government newspapers.

Turkey's Jews, most of whose ancestors sought refugee here from the Spanish Inquisition, are on edge. Their school and synagogues are behind security tunnels, shielded by steel blast protection.

"They have lived in a state of fear for a long time after terror attacks and the feeling that they are not treated as Turkish citizens. There is worry for the younger generation," said Ohad Kaynar, Israel's deputy consul general.

Louis Fishman, an expert on Turkish affairs at Brooklyn College in New York, saw evidence of government indifference to anti-Semitism. "Buildings might be protected but the people who visit them are subjected to regular hate speech and threats," he said.

Erdogan's spokesmen and other officials did not respond to requests for comment for this article. However, the Turkish government has been at pains to distinguish between its Israel policy and its attitude towards Turkey's Jewish population.

Former friends

Close allies under previous governments, Israeli-Turkish ties hit a nadir in 2010 when Israeli commandoes stormed a Turkish-led convoy of ships carrying aid to Gaza and killed 10 Turks. Turkey withdrew its ambassador and ejected Israel's.

"Regardless of the fact that we identify ourselves as Turks, we are still perceived as foreigners. Tensions between Turkey and Israel directly impact us," said Karel Valansi, a political columnist with Salom newspaper.

For centuries, Ottoman lands were a haven for Jews, welcoming Sephardim expelled in 1492 by Spain.

Once here, they adopted new rituals, such as the melody of the azan in their prayers, while maintaining their traditions, most prominently the Judeo-Spanish dialect called Ladino.

Census data shows Ladino was the mother tongue for 84 percent of Turkish Jews in 1927 before nationalist campaigns stamped it out. Today only a few elderly speak the archaic form of Castilian Spanish, one of the world's endangered tongues.

A "wealth tax" in the 1940s, emigration to Israel after 1947 and decades of political instability conspired to decimate a population that was 150,000 before World War One.

Spain and Portugal are redressing historical wrongs by offering citizenship, bound to prompt some to pull up stakes.

"Jews have long left for economic reasons. What is different now is a factor for young people is the pressure they feel because they're Jewish," said Mois Gabay, 31, who writes for Salom. He cited figures showing one in four Jewish high-school graduates opted to study overseas in 2014, doubling in one year.

But the decline is mainly due to a death rate that exceeds births threefold, said Naim Guleryuz, the Jewish museum curator.

Hatred flares

At Istanbul's main Neve Salom synagogue, vandals in November hung a fake demolition notice close to the anniversary of a string of 2003 car bombings claimed by al Qaeda that targeted Jewish temples and British interests, killing 57 people.

Even the opening of the Edirne synagogue was at risk. The governor said it would be a museum instead and that he felt "hatred" after Israeli police entered al Aqsa mosque in November. He later apologized, and restoration work continued.

"This is not only Jewish but a part of Turkish and world heritage. It is proof that we have lived together and still do," said Guleryuz, author of a book on Edirne's Jews. "If we occasionally celebrate a wedding, we can keep it alive."

The synagogue's bright yellow exterior is a burst of light among the dilapidated wooden houses and concrete apartment blocks in Edirne's former Jewish quarter. Inside, painters painstakingly decorated the ceiling with thousands of stars, as beams of sunlight passed through a colonnade of neat arches.

"It looks like its old self," said Mitrani, standing beside the polished marble of the ark bearing the Ten Commandments.

Once the Balkans' largest Jewish temple, the Great Synagogue opened on the sultan's decree in 1909 to serve some 20,000 Jews. It was modeled on a temple in Vienna, later destroyed by the Nazis.

Thousands of Jews left Edirne, situated near the Greek and Bulgarian borders, in 1934 when a racist mob attacked their property, but Mitrani's father, a grocer, rebuilt his shop.

Mitrani, who owns two supermarkets here, travels to Istanbul each week to join his wife and daughters for the Sabbath.

He planted a pine tree next to his mother's grave in the old cemetery, part of which has been occupied by a housing complex that uprooted graves. Litter is strewn among hundreds of broken headstones, which include the odd Greek Orthodox inscription.

"I would have liked to have been buried in Edirne, next to my mother," Mitrani said. "Staying was always the easiest thing for me. I can't imagine the day I won't be here."