ANKARA, Turkey (CNN) -- Turkey's top court has upheld a ban on wearing Muslim headscarves at the country's universities.
The Constitutional Court ruled that the Turkish Parliament overstepped its bounds earlier this year when it passed constitutional amendments that would have led to allowing universities granting women the right to wear headscarves.
The ruling -- which said the legislation counters Turkey's secular legal principles -- is a setback for Turkey's ruling AK party, which supported the legislation.
The legislation sparked public protests from many Turks who believe that the move would threaten Turkey's existence as a secular state.
Lawmakers had agreed to approve two constitutional changes that would have allowed female students to wear headscarves -- a form of dress that has been prohibited in Turkish universities since a constitutional court ruling nearly two decades ago. Opposition Republican People's Party lawmakers immediately appealed the ruling.
Although a predominantly Muslim state, Turkey has taken the trappings of religion out of public life, in accordance with the policies of Kemal Ataturk, the revered founder of the modern Turkish republic.
Turkey's constitutional court banned headscarves from the country's universities in 1989 and it is still forbidden for women working in the public sector to cover their heads, even though the regulation is regularly flouted.
The AK party, led by Prime Minister Recep Tayyip Erdogan, argued that the university ban is an unfair denial of individual rights and religious liberty in a country where two-thirds of women still cover their heads.
In a separate case at the Constitutional Court, Turkey's chief prosecutor is seeking to disband the ruling party because it is "the focal point of anti-secular activities." The headscarf issue is given as one example of such alleged anti-secularism.
The Constitutional Court ruling is seen as a weather vane for a ruling on the AK party. The court could have dropped the case or taken softer options to the amendments, but it took the toughest interpretation of the law.
Journalist Andrew Finkel contributed to this report