ISTANBUL, Turkey - Turkey's top court said Wednesday that it will not ban the ruling party for allegedly trying to steer the country toward Islamic rule, a decision that preserves a government locked in a power struggle with the secular elite.

The Constitutional Court, however, delivered a strong warning to the Justice and Development Party and said it would be deprived of half of its funding from the state treasury.

"The decision was a warning, a serious warning," court chairman Hasim Kilic said after three days of deliberations.

He said six of the 11 judges wanted to ban the party of Prime Minister Recep Tayyip Erdogan. However, a total of seven votes were needed under court regulations.

The decision represented a reprieve for Erdogan and his allies in an overwhelmingly Muslim country with a secular system that seeks to join the European Union. A decision to ban the party would have triggered a sharp escalation in political turmoil in the NATO member country, where a bomb attack Sunday killed 17 people in a mostly residential area of Istanbul.

A ban would have severely damaged Turkey's image as a democracy because the ruling party won a strong majority in elections last year; EU leaders have said the ruling party's viability should be decided in elections, not courtrooms.

The court case was the latest battleground between the pious Muslims who run the government but embrace aspects of western political and economic systems, and the secular establishment that draws support from the military and judiciary. The rift has evolved over the last century since national founder Mustafa Kemal Ataturk jettisoned Islam as a guiding force in society and politics, instead imposing a strictly secular system amid the ruins of the Ottoman Empire.

In March, Turkey's chief prosecutor asked the Constitutional Court to disband Erdogan's party and bar him and 70 other party members from joining a political party for five years.

President Abdullah Gul was also on the prosecutor's list.

Prominent party leaders have backgrounds in political Islam, and the party itself is a successor to parties that were banned in the past. But those leaders now say they are not following an Islamic agenda, citing EU-backed reforms as proof.

"This party is definitely advocating a more moderate streak of thought than its predecessors," said Ilter Turan, a political science professor at Istanbul's Bilgi University. Earlier, Turan said: "No matter what the decision is, this case shows that Turkey needs a restructuring of its laws and a constitutional reform."

The judges began hearing the case Monday, a day after two bomb explosions at a packed Istanbul square. It was the deadliest attack in Turkey in almost five years. Turkish officials blamed Kurdish rebels, who denied responsibility.

The timing of the attack -- on the eve of the Constitutional Court's deliberations -- raised questions about whether there was a link of some kind. Prosecutors are also preparing a case against alleged coup-plotters, including retired army officers, who stand accused of trying to bring down the Islamic-oriented government by fomenting chaos in Turkey.

The conflict between the government and secular opponents escalated last year during Gul's candidacy for the presidency, and the military delivered a warning to the government that recalled past coups by the armed forces. But the Justice and Development Party triumphed by winning 47 per cent of the votes in general elections, and 341 seats in the 550-seat Parliament.

This year, the party attempted to lift a decades-old ban on the wearing of head scarves at universities, but the top court overturned that bill, saying it was anti-secularist. Chief Prosecutor Abdurrahman Yalcinkaya cited the head scarf bill as proof the government is trying to scrap secularist principles enshrined in the Constitution.

The court has banned two dozen political parties since it was established in 1963. But none had such strong electoral support as the current ruling party.