ANKARA (AFP) - Turkey's Islamist-rooted ruling party narrowly escaped being banned Wednesday for undermining secularism as the Constitutional Court decided to punish it with financial sanctions instead. Six of the court's 11 judges voted in favour of closing down the Justice and Development Party (AKP) - just one short of the seven required to implement a ruling, court president Hasim Kilic said. But he added that the court was still sending the party a "serious warning" by cutting half of the treasury funds it was entitled to this year. The ruling appeared to offer a compromise solution to Turkey's political problems, sparing the country the sort of turmoil a full ban might have unleashed, while also urging the AKP to toe the line. "I hope the party in question will evaluate this outcome very well and get the message it should get," Kilic said. The judges who supported the financial sanctions said the AKP had become a "focal point" of anti-secular activities as the country's chief prosecutor argued, "but not that serious," he said. The AKP, which won a resounding re-election victory last year, was quick to hail the court decision as a victory for democratic principles. "With this decision, the bar of democracy has been lifted up," parliamentary speaker Koksal Toptan was quoted as saying by the Anatolia news agency. Defence Minister Vecdi Gonul said the ruling was "of extraordinary importance" in Turkey's legal history. "Turkey has been saved from uncertainty. Turkey will continue on its way in confidence and stability," he said in the western city of Izmir. Prime Minister Recep Tayyip Erdogan's party was accused of seeking to replace Turkey's secular system with a regime based on Shariat. Chief prosecutor Abdurrahman Yalcinkaya had also called for the court to bar President Abdullah Gul, Erdogan and 69 other AKP officials from party politics for five years. EU foreign policy chief Javier Solana welcomed the ruling as "good news," his spokeswoman said. "Turkey is leaving a tense situation and we very much hope that the decision by the court will contribute to restoring political stability," she added. The prosecutor had argued that the secular Turkish republic was in grave danger and accused the AKP of using the advantages of democracy to achieve a government model "which involves violence." His key argument was an AKP-sponsored constitutional amendment passed in February that aimed to abolish a ban on the Islamic headscarf in universities. The Constitutional Court ruled that the amendment violated secular principles and scrapped it in a separate case in June. The prosecutor also cited attempts by AKP municipalities to ban or restrict alcohol sales and promote religious education and Islamist lifestyle. Most of his other evidence comprised statements by Erdogan and other AKP members in favour of broader religious freedoms.