ANKARA, Turkey - A  sea of flag-waving demonstrators poured into the streets of the capital Saturday to protest a possible presidential run by the pro-Islamic prime minister, whose party has been eroding secular Turks' longtime grip on power.

With a crowd estimated at more than 300,000, the protest was one of the country's largest in decades. Red Turkish flags hung from balconies and windows and fluttered in the hands of protesters, who chanted, "We don't want an imam as president!" and "Turkey is secular and will remain secular!"

Prime Minister Recep Tayyip Erdogan has brandished his strong religious convictions, speaking out against restrictions on wearing Islamic-style head scarves in government offices and schools, and taking steps to bolster religious institutions in this country founded on the principle of secular rule.

He also tried to criminalize adultery before being forced to back down under intense pressure from the European Union, which Turkey is trying to join.

The country's pro-secular president, Ahmet Necdet Sezer, has been a brake on the pro-Islamic movement but is stepping down on May 16. Erdogan's Justice and Development party, which dominates parliament, is expected this month to announce its candidate to replace Sezer in the appointed presidency. Erdogan is expected to announce whether he will run after a meeting with his party on Wednesday.

If he runs, the party is expected to select him as president. Another pro-Islamic official could then be selected for the premiership, placing the executive branch entirely under the control of the Islamic-leaning ruling party.

Turkey aspires to become the first Muslim member of the European Union, and has long touted itself as a bridge between the Western and Islamic worlds. Erdogan enjoys some support in Europe and the United States, where backers hold up Turkey as proof that devout Islam and democracy can be compatible.

But many opponents at home are suspicious. Tens of thousands travelled from across the country overnight to attend the rally in downtown Ankara.

Military officials estimated the crowd at more than 300,000, while organizers said the total number of participants was more than a million. Military estimates of past demonstrations have generally proven more accurate than organizers' numbers.

Police cordoned off the official meeting area - near the mausoleum of Mustafa Kemal Ataturk, the revered founder of modern Turkey and the symbol of its secular identity.

Starting in 1923 in the ruins of the Ottoman Empire, Ataturk, a soldier, set about on a series of secular reforms that imposed Western laws, replaced Arabic script with the Latin alphabet, banned Islamic dress and granted women the right to vote.

The fiercely pro-secular military staged three coups between 1960 and 1980, pressured a pro-Islamic premier - Erdogan's mentor - out of power in 1997, and retains a strong influence over politics.

"We hope that someone who is loyal to the principles of the republic - not just in words but in essence - is elected president," Gen. Yasar Buyukanit, chief of the military, said Thursday in a statement widely interpreted as a warning to Erdogan not to run.

Any serious tensions between the government and the military could have a serious effect on the economy, analysts warn.