When Yunus Genc prays on Friday at Hagia Sophia, it will mark the triumphant culmination of decades-long efforts by Islamist-rooted groups like his to convert the ancient monument, revered by both Christians and Muslims, to a mosque.

Genc's Anatolian Youth Association (AGD) held protests and organised prayers outside the 1,500-year-old Hagia Sophia, while another group waged a series of failed legal campaigns until a top Turkish court last month finally ruled in their favour, annulling its status as a museum.

President Tayyip Erdogan immediately declared the building — a Christian Byzantine cathedral for 900 years before it was seized by Ottoman conquerors and served as a mosque until 1934 — a mosque once more, with first prayers to be held on Friday.

The decisions unleashed a torrent of criticism from church leaders, who said the conversion to exclusively Muslim worship risked deepening religious divisions.

Turkey says the site will remain open for visitors and its Christian artworks protected.

"We struggled for this for years," Genc said in front of the mosque, whose huge grey dome and rose-coloured walls and buttresses have marked the city skyline for a millennium and a half, joined later by four towering minarets.

"Hagia Sophia is a symbol and we, like all Muslims, wanted it opened as a mosque...When Sultan Mehmet the Conqueror came to Istanbul he bought Hagia Sophia with his own money as a symbol of the conquest, endowed it and wanted it to be a mosque."

Genc's AGD group is an offshoot of a movement founded by Turkey's first Islamist prime minister Necmettin Erbakan, whose political party was a forerunner of the AK Party which has ruled Turkey under Erdogan's leadership for 17 years.

Amid the chaos and uprisings which shook the Middle East since 2011, Erdogan sought to position Turkey as a regional power.

The Hagia Sophia move was a sign towards "achieving freedom" for Al Aqsa mosque in Jerusalem, Erdogan said earlier this month.

Erdogan threw his weight behind the campaign to convert Hagia Sophia before local elections last year which dealt a painful blow to his ruling AK Party.

Officials say the move addresses a deep-rooted wish within the country.

"The decision to turn the Hagia Sophia museum into a mosque is based on a long-standing demand by the vast majority of the Turkish people," presidential spokesman Ibrahim Kalin said.

"We believe it makes more sense to use it...as a house of worship."

He said under Erdogan's rule, churches and synagogues serving Turkey's minority Christian and Jewish communities had also been built, or rebuilt.

In Hagia Sophia, the Christian frescoes and the glittering mosaics adorning the cavernous dome and central hall will be concealed by curtains during Muslim prayer times, but remain on display for the rest of the time.

"That's part of the Islamic legal tradition, just like the Jewish tradition where you are not supposed to have many descriptions and paintings, while you're praying," Kalin said.

"They will be covered during prayer times, and other times they will be open to everyone," he told Reuters.

Icons and artwork in the building's upper floors and side galleries would remain uncovered, he added.

Pictures from inside Hagia Sophia this week have shown a large carpet being laid on the floor in preparation for the prayers.