ANKARA - Some 25,000 Turks have marched to defend secularism, which they said was under threat after a judge was shot dead by a gunman declaring himself a "soldier of God".

Angry crowds directed their anger at Prime Minister Tayyip Erdogan's government which secularists accuse of having a secret Islamic agenda of bringing religion into public life.

Crowds booed and jostled government ministers as they tried to enter the Ankara mosque for the funeral of slain judge Mustafa Ozbilgin.

"Murderers get out" and "government resign", dozens shouted as police tried to clear the way for the ministers, including deputy Prime Minister Abdullatif Sener.

Police said an Islamist lawyer burst into the top administrative court, or Council of State, on Wednesday, shot dead Ozbilgin and wounded four others. One of the judges said the gunman shouted he was a soldier of God.

Police have detained 9 suspects, media said.

Islamists, but also Erdogan, criticised the court after it barred a woman in February from becoming a headteacher because she wore a headscarf. It was that ruling that made the judges a target, the council's deputy chairwoman said.

The headscarf has come to symbolise a much broader struggle over the role of religion in overwhelmingly Muslim Turkey.

Erdogan's Justice and Development Party (AKP) emerged from two banned Islamist parties, but denies any religious agenda. Erdogan and the AKP have strongly criticised the ban on the headscarf in universities. Erdogan's own wife wears a headscarf.

Secularists say the headscarf is the tip of an Islamist iceberg and accuse Erdogan and of trying to create an Islamic state by stealth.

In contrast to the reception received by ministers, secularist President Ahmet Necdet Sezer and top generals were applauded as they arrived for the funeral. The army is seen as the ultimate guarantor of the secular system in Turkey.

"You must be alert and watchful against the dangers and risks that target our republic," Sezer warned Turks in a statement to mark Friday's public holiday.

Judges led thousands to Mustafa Kemal Ataturk's mausoleum to pay homage to the republic's founder and support secularism. Many more trailed the judge's coffin to the funeral service.

Residents said it was the largest secularist protest in Ankara since those following the 1993 car bomb killing of a newspaper columnist.

"We have to rally against the people who brought our country to this point," said Ankara housewife Gumus Ocak. "We're so sorry about this attack and therefore we all want to be on the streets and make our voices heard."

Turkey's political and military leaders, including Erdogan, have condemned the attack. Erdogan called on Turks to unite and not use the killing for political ends.

The attack is a setback for the AKP in its quest to lift the profile of Islam in Turkey and ease limits on the headscarf, worn by most women in Turkey as a sign of devoutness.

Tensions between the powerful secularist establishment and those they perceive as Islamists bent on reviving the influence of religion in national life have escalated in recent months amid early election rumours.

- REUTERS