Turkey's foreign minister, Abdullah Gul, was elected president on Tuesday, the parliament speaker said, in a major triumph for the Islamic-rooted government after months of confrontation with the secular establishment.

Gul received 339 votes in a parliamentary ballot, Parliament Speaker Koksal Toptan said. The victory made him the first head of state with a background in political Islam in a country with strong secularist principles.

"Abdullah Gul was elected Turkey's 11th president, with 339 votes," Toptan said. "I congratulate him." Ruling party legislators broke into applause.

Two other candidates, Sabahattin Cakmakoglu of a nationalist party, and Tayfun Icli of a small center-left party, got 70 and 13 votes, respectively.

A day earlier, the military — which has ousted four governments since 1960 — issued a stern warning about the threat to secularism.

Gen. Yasar Buyukanit, chief of the military, said in a note on the military's Web site: "Our nation has been watching the behavior of those separatists who can't embrace Turkey's unitary nature and centers of evil that systematically try to corrode the secular nature of the Turkish Republic."

Gul's initial bid for president was blocked over fears that he planned to dilute secular traditions.

Gul failed to win the presidency in two rounds of voting last week because the ruling Justice and Development party lacked the two-thirds majority in Parliament needed for him to secure the post. But the party — which holds 341 of the 550 seats — had a far easier hurdle on Tuesday, when only a simple majority was required.

Gul, 56, has promised to uphold secularism. But Turkey's president has the power to veto legislation, and Gul has failed to allay secularist fears that he would sign into law any legislation passed by the government of Prime Minister Recep Tayyip Erdogan — a close ally — without concern for the separation of religion and politics.

Also, his wife wears an Islamic-style head scarf — which is banned in government offices and schools. Islamic attire has been restricted in Turkey since the country's first president, Mustafa Kemal Ataturk, ushered in secularism and Western-style reforms in the 1930s.