The constitutional court ruled that not enough parliamentarians were present when the first round of the presidential vote was held in the 550-seat assembly on Friday.

The court ruled that the government needed 367 members or two-thirds of the chamber to get its candidate, Abdullah Gul, through the first round.

Only 361 deputies voted, 357 of them for Gul, the sole candidate.

Parliament, in which the AK Party has a big majority, elects the president for a seven-year term in predominantly Muslim Turkey.

The secularist establishment says Erdogan and Gul, who is foreign minister, want to break the separation of state and religion, but the two men have rejected the charge.

Analysts say early national polls are the only way to defuse the standoff.

Secular groups have been calling for early national polls which were initially scheduled for November.

They want the secular system established by the founder of modern Turkey, Mustafa Kemal Ataturk, 84 years ago, to be retained.

But a growing class of prosperous and more religious-minded Turks want a relaxation of curbs on religious symbols and expression.

Markets rattled

Erdogan's AK Party is widely expected to win the presidential polls, but the standoff has rattled Turkey's financial markets, recording their biggest falls in a year on Monday.

"I told EU officials Turkey would return to a more democratic process with elections"

Recep Tayyip Erdogan, Turkey's Prime Minister

The Turkish currency lost more ground on Tuesday as concern grew about possible instability after an anti-government rally of up to one million on Sunday and the army's threat to intervene in politics to prevent an Islamist president from the threatening the country's secular constitution and identity.

Erdogan tried to sound a positive note on Tuesday.

He said: "I see Turkish markets will improve in the next few days with our positive steps in politics.

"I told EU officials Turkey would return to a more democratic process with elections, and the democratic process in Turkey will successfully continue."

Defiance

Erdogan, in a clear move to identify with the people, proposed that future presidents be elected by voters instead of parliament.

The government has also made remarks in a display of unprecedented defiance against Turkey's military generals.

He said: "In democracies there is no better way of making warnings [to the government] than ballot boxes."

The Turkish army has ousted four governments since 1960, the last in 1997.

Shock defeat

Barnaby Phillips, Al Jazeera's correspondent in Ankara, said the court ruling was a clear defeat for the ruling party and there was disappointment within.

"Senior AK Party officials have told us they did not expect this verdict," he said.

Parliament will vote again on Wednesday before an election date is set, government officials said.

Phillips said the AK Party may go to parliament anyway and try and resume the process of getting Gul elected as president.

He said they may be hoping to do a deal with some of the smaller parties, particularly with the Motherland Party which has about 20 members.

"If they do succeed in winning them over, they may succeed in getting the majority that they need to get Abdullah Gul elected as president."