At the foot of the famed UNESCO-listed Casbah district in Algiers, the Ketchaoua Mosque has had a tumultuous past that, at one point, saw it turned into a cathedral under French rule.
Now the ornate towers and arches are set for a new chapter as the majestic place of worship gets ready to open its doors for the first time in nearly a decade following a lengthy renovation.
Once a symbol of Ottoman influence, it was known for more than a century as the Roman Catholic Saint Philippe Cathedral after France's conquest of Algeria, only to revert to a mosque when the country claimed independence in 1962 following a bloody struggle.
In 2008 it was shut down as the ravages of time - and a powerful earthquake - took their toll.
But much to the delight of local residents it will soon be up and running again after more than three years of restoration work, funded by the Turkish government.
"I can't wait to return there to pray," said Salim, a trader working nearby, who declined to give his second name.
"My father brought me here to pray for the first time in 1978 when I was just 9 years old."
The date of the first mosque built on the site remains under debate but the earliest references to it can be found in 1612.
In the late 18th century, the Ottoman ruler of the region, Hassan Pasha, completely transformed the location and turned it into one of the grandest mosques in the city.
That lasted only for around 40 years until the French seized Algeria and requisitioned the building by force.
"Its conversion into a church in 1832 took place after an assault by the colonial army" that claimed the lives of some of "the several hundred faithful who had dug in to oppose the takeover," said Aicha Hanafi, professor of archaeology at the University of Algiers.
"That same year, on Dec. 24, they celebrated the first Christmas Mass," she said.
The Christian capture of the mosque brought both a physical and spiritual change to the building.
A large part was knocked down as the site was enlarged to become the city's principal cathedral.
Two bell towers, designed in an Eastern style, were erected, framing a new entrance at the top of a grand staircase.
Its first women
After returning to its original function following independence some 55 years ago, the mosque underwent cosmetic changes to make it conform to the demands of the Muslim faith.
Now the latest renovations have seen a greater overhaul, restoring more original features and making space for some 1,200 faithful, including, for the first time, women.
"We did all that we could to maintain the historical monument," said Abdelouahab Zekkagh, director of the national agency that oversees the use of historical buildings.
He said the minarets were taken apart stone by stone and those blocks that were too badly worn were swapped for new ones bought in from the west of the country.
The original minbar (pulpit) built by the Ottomans in 1794 has been restored and the niche indicating the direction of prayer has been repainted in gold leaf by a Turkish craftsman.
Architect Akli Amrouche is slightly disappointed that the new verses of the Koran inscribed on the walls do not match the originals.
But, overall, after the long road that the mosque has traveled he is happy with the facelift.
"It is an excellent job, the minarets have been saved and the prayer room renovated," he said.