Abdullah Gul's presidential ambitions have long alarmed Turkey's secular establishment.
His election as president makes him the first politician with an Islamist background to become head of state since the Turkish Republic was established in 1923.
Secularist parties boycotted a parliamentary vote on Mr Gul's candidacy in April, blocking his presidential bid and creating political deadlock. He was foreign minister at the time.
Abdullah Gul has powerful backing from the ruling AKP
The ruling AK Party, which Mr Gul helped found, decided to re-nominate him, arguing that a sweeping general election victory in July had given it the mandate to do so.
Nevertheless, secularist opposition to Mr Gul remains strong.
The military has frequently warned it would intervene to protect the secular system if required.
On 27 August - the eve of the decisive third round of voting in parliament - the head of Turkey's armed forces, Gen Yasar Buyukanit, spoke of "centres of evil" trying to undermine the state.
In May, millions of Turks marched against the AKP nominating the next president.
But the AKP then went on to win almost one in every two votes in an early parliamentary election.
Mr Gul, 56, says he has cut his ties to political Islam and points to more than four years as foreign minister, working for democratic reform and Turkey's EU membership.
Turkey has maintained a strict separation of religion and politics since it became a republic.
Secularists dislike the fact that Mr Gul's wife wears the Islamic headscarf. She will be the first First Lady to wear it - even though it is unclear how this can be done inside the presidential palace, as the headscarf is banned from state institutions.
The Turkish president has the right to veto laws and dissolve parliament. The president also appoints the prime minister and some key figures in the establishment.
Mr Gul is certainly an experienced politician.
He has steered Turkey's European Union accession talks since becoming foreign minister in 2003.
He also served as prime minister in late 2002 and early 2003, but was always a stop-gap for Mr Erdogan.
Mr Erdogan had a criminal conviction for reading an Islamist poem at a political rally and was barred from the 2002 election.
Mr Gul served to oversee changes to the constitution and, after a by-election, allowed Mr Erdogan back into parliament. Mr Gul quickly stepped aside.
However, Mr Gul is no stranger to the secular-religious controversy and some analysts say he is as close, if not closer, to his religious roots as Mr Erdogan.
Secularists fear that with the AKP controlling both parliament and presidency it may push an "Islamic agenda".
Hayrunisa Gul is set to be the first headscarf-wearing First Lady
Mr Gul has tried to sound conciliatory, with phrases such as "If I am elected I will act accordingly" and a pledge to adhere to secular principles.
On the headscarf issue, he stood by his support for them, but avoided being contentious, saying "these are individual preferences and everybody should respect them".
The issue of Cyprus has remained a constant thorn for Mr Gul.
During his brief stint as prime minister he pinpointed it as one of his key priorities. But four years later Cyprus remains a key stumbling block to Turkey's EU membership.
Last year, Mr Gul said Cyprus was "poisoning" Turkey's EU accession process.
Mr Gul has also criticised US policies in the Middle East, saying Washington's support for Israel in its conflict in Lebanon last year had caused a backlash in Turkey.
He said moderate Turks were in danger of becoming anti-American.
Other key issues on his agenda have been Syrian relations and Kurdish separatists.
Abdullah Gul was born in Kayseri on 10 October 1950.
He graduated in economics from Istanbul University in 1971 and received a PhD there in 1983. He also studied in the UK.
Mr Gul, an English and Arabic speaker, joined parliament in 1991 as a member of the Welfare Party.
In 1999, he was re-elected as a member of the Virtue Party, Welfare's successor, but in 2000 he narrowly lost a bid to replace Recai Kutan as Virtue's leader.
Mr Gul then became a founder member of the AKP in 2001.
He married Hayrunisa Ozyurt in 1980 and the couple have two sons and a daughter.