Muslim women protested against the court's verdict
Turkey's ruling party has held an emergency meeting after its landmark measure allowing students to wear headscarves was blocked.
The Constitutional Court said the move to overturn a ban on scarves violated the constitution's secular principles.
PM Recep Tayyip Erdogan met AK Party officials on Friday to discuss the next step, while Muslims held protests.
Correspondents say the court ruling could foreshadow the outcome of a case in which the AK Party could be banned.
Turkey's chief prosecutor says the ruling AKP is "the focal point of anti-secular activities" and is seeking to have it disbanded.
Some 71 members of the party, including the prime minister and the president, could also be banned from belonging to a political party for five years.
The prosecution case cites the constitutional amendment allowing girls to wear headscarves to university as evidence that the AK Party has an anti-secular agenda.
The headscarf ban is seen by some as one of the cornerstones of the secular state - a symbol of the exclusion of Islam from state activities.
The government argues that banning headscarves at colleges stops many Muslim girls being educated and says it is a matter of personal freedom.
But the secularist establishment, which includes the army, courts and universities, suspects the AKP, which has its roots in Islamism, has a hidden agenda.
Hundreds of protesters, many of them women in headscarves, protested in several cities across Turkey on Friday to express their anger at the court's move.
"I am crushed and feel hopeless," said 29-year-old Esra Altinay Ozbecetek.
The Turkish press agreed that the ruling upholding the headscarf ban had been Mr Erdogan's "greatest political defeat" since the AKP came to power in 2002.
The ruling is a blow to PM Erdogan and his wife
"A decision to close down the AKP has become inevitable," the Vatan newspaper wrote.
Some AKP figures believe party members will have to set up a new party and possibly even call an early general election, only a year after it won a convincing poll victory, says BBC correspondent David O'Byrne in Istanbul. A senior party member of the AKP, Bekir Bozdag, said the Constitutional Court had overstepped its jurisdiction with its headscarf ruling.
But senior leaders, including the prime minister and president, have yet to comment.
Having lost this case, they are already likely to be focusing on the ongoing legal threat to their party and positions, our correspondent says.