TRIPOLI // In the inner court of the Turgut Pasha mosque in the Libyan capital's old medina is a low green sarcophagus, and in the sarcophagus are the bones of a pirate.
The Turkish corsair Turgut Reis helped capture the city for the Ottoman empire in 1551, wresting it back to Islam from the Knights Hospitaller after four decades of Christian rule.
"The tomb of Turgut is a kind of relic," said Walid al Masri, a local imam visiting the mosque on a recent Friday for the midday prayer. "It's just one reason why more must be done to protect holy places here."
Such historic buildings help make Tripoli's medina a monument to Libya's past, while crumbling architecture and an influx of poor migrants reflect modern problems. With state restoration plans afoot, residents hope to see the neighbourhood flourish again. Skyscrapers are rising along Tripoli's waterfront as Libya mends ties with western countries and the economy gathers speed. But the medina has fallen into disrepair.
Founded in the seventh century BC by Phoenician traders, the city passed through Roman, Vandal and Byzantine hands before Libya's conquest in the late seventh century by Arab armies that brought Islam to North Africa.
The advent of Ottoman rule saw Turgut strengthen the medina as governor before succumbing to cannon-fire at the siege of Malta in 1565. Twentieth-century Italian colonisers added the neoclassical arcades of the city's modern downtown.
In 1969, Libya's leader, Moammar Qadafi, toppled its pro-western monarchy and set up a system of committees with himself as "brother leader and guide of the revolution".
Libyan support for militant groups under Mr Qadafi led to United Nations sanctions in 1992, which were lifted in 2003 after Libya surrendered suspects in the 1988 Lockerbie bombing and renounced its quest for nuclear weapons. US sanctions, dating back to 1986, were lifted the following year.
With cash flowing again, Libya's government is developing infrastructure such as roads, airports and commercial districts. Medina residents are eager for more state spending in their neighbourhood, too.
"The streets need to be paved, and everywhere power lines are exposed," said Abdelhamid el Shemaa, a retired mechanic, leaning from his kitchen window near the Turgut Pasha mosque. Born in Syria to Libyan parents, Mr el Shemaa and his wife have lived in the medina since 1976. "But none of our children live here anymore, they all wanted larger, more comfortable houses," he said.
In the alley below, a rubbish collector was manoeuvring his pushcart through the mud of a winter rain.
"The municipality picks up the rubbish, that's a good start," Mr el Shemaa said. "But other improvements should go faster, and houses must be made beautiful again."
While Mr el Shemaa's building is intact, the one opposite is an abandoned shell, with fallen masonry visible through the sockets of windows.
Libya's government hopes that a planned restoration programme will breathe life back into the medina.
"Restoring the urban fabric of the old city is like silversmithing: you go part by part," said Ahmed Imbeis, an architecture professor at Tripoli's Al Fateh University and consultant to the Engineering Consulting Office for Utilities, a state agency that is planning the medina's restoration.
The agency proposes advancing in stages, paving streets and expanding the electricity grid before refurbishing the medina's gates and main streets, Mr Imbeis said. However, too piecemeal an approach could risk damaging the medina's complex architecture, said Ron Packman, a London architect and restoration expert who has studied the neighbourhood.
"Buildings of various ages have relapsed against one another," he said. "If you start working on one building, whatever you do could adversely affect those around it."
Mr Packman hopes to undertake an archaeological survey and restoration of the medina's Al Naqa mosque, believed to date to the seventh century. "We have to let archaeology take precedent, but it will inform the restoration process," he said. He believes that proper planning "can keep the community going and preserve a medieval street pattern that is still living".
Those streets also reflect 21st-century realities, as Libyan homeowners are replaced by thousands of mainly sub-Saharan migrants. One such newcomer is Mehdi Hisian Omar, 25, a lanky Sudanese day labourer, who works at building sites.
In 2006, he was walking to evening prayer in the town of El Geneina in Darfur when eight Janjaweed horsemen appeared, spraying bullets, he said. Shot through the chest, he was treated at a United Nations clinic. A year later, with his family scattered and his father arrested for alleged ties to Sudan's political opposition, Mr Omar fled to Tripoli.
"I came here to the medina because the rent is cheap," he said. "My goal was to earn some money and find my family. I still have this goal, but no success."
Meanwhile, Mr el Shemaa's family is reunited most weekends when his children and grandchildren visit.
"There's a strong sense of community here, and my kids still feel attached," he said. He withdrew from his window to the living room, where his grandson, Ramy, was playing computer games beneath a medieval arch. "That's the medina," Mr el Shemaa said, motioning towards the boy. "The ancient and the modern under the same roof."