Turkey's Constitutional Court has decided not to ban the ruling AK Party, accused of undermining the country's secular system.
But the judges did cut half the AKP's treasury funding for this year.
The AKP, which won a huge poll victory last year, denies it wants to create an Islamist state by stealth. It called the case an attack on democracy.
The powerful military sees itself as the guardian of the modern secular state founded by Mustafa Kemal Ataturk.
Court president Hasim Kilic said the financial sanctions imposed on the AKP were a "serious warning".
Narrow decision
At least seven of the 11 court judges would need to vote in favour for the party to be banned. But six judges wanted a ban and five did not want to do so.
MP Suat Kinklioglu speaks of the AK Party's relief at the court's decision
"I hope the party in question will evaluate this outcome very well and get the message it should get," Mr Kilic said.
After the ruling, Turkey's Labour Minister Faruk Celik was quoted as saying it was a "victory for Turkish democracy".
The court case followed a series of confrontations between the AKP, which has Islamist roots, and the secular elite. Turkish secularists have staged huge anti-AKP rallies.
The party's attempt to allow Islamic headscarves to be worn at universities was highly controversial.
Last month the constitutional court said the move to lift the existing headscarf ban violated the secular constitution.
Since the 1960s, more than 20 parties - mostly pro-Islamist or pro-Kurdish - have been shut down by the courts for allegedly posing a threat to Turkey's secularist principles.
However, this is the first time that a closure case has been brought against a governing party with a huge parliamentary majority.
EU officials expressed some relief at the court's ruling on Wednesday.
"It is positive. Turkey is living a tense situation and we very much hope that the decision by the court will contribute to restore political stability," said Cristina Gallach, spokeswoman for EU foreign policy chief Javier Solana, quoted by Reuters.
Bookmark with:
What are these?