By Sarah Rainsford
BBC News, Ankara
It took more than four months, but Abdullah Gul has finally been elected president - a former Islamist, sworn in as head of this strictly secular state.
Mr Gul is seeking to reassure the army and secularist parties
With 339 votes, he left his two opponents trailing far behind.
It was a resounding victory, with well over the support in parliament that was required.
But Mr Gul's path to the presidency has been mired in controversy, amid claims he and his AK Party are a threat to the secular system.
There have been huge street protests and an election boycott.
The first vote was annulled by the Constitutional Court. And on the eve of the final vote, Turkey's most senior general claimed what he called "centres of evil" were working to corrode the values of the Republic.
The AKP has always argued that most Turks disagree with such dire warnings.
It believes that was proved on 22 July, when it called an early general election and scooped almost 47% of the vote. Abdullah Gul was promptly re-nominated for president.
In his first speech in office Abdullah Gul confronted his critics head-on.
Senior military commanders boycotted Mr Gul's inauguration
"The Turkish Republic is a democratic, secular and social state governed by the rule of law," he told an invited audience in parliament.
"I am determined to uphold these principles and to further strengthen them at every opportunity," he said.
"His first speech is secularism!" was the response from the Hurriyet daily the next morning.
It also contained quotes from the revered founder of the Republic - Ataturk - and praise for the Turkish military. Hurriyet says the president now has to convince his opponents he means it.
The election of Abdullah Gul has already been welcomed abroad. As foreign minister, he earned widespread respect on the international stage as champion of Turkey's efforts for EU membership.
Here at home, reconciliation may not be so easy.
Turkey's senior military commanders did not attend the inauguration ceremony for Abdullah Gul - now their commander in chief. It was an unprecedented snub.
The republican opposition CHP party boycotted the election.
"A president should have the approval of the large majority of the public," CHP deputy chairman Onur Oymen explained. "This is not the case for Abdullah Gul. I hope his election will not lead to tension and friction in society."
The first lady's Islamic headscarf is a source of controversy
At the root of much of the debate has been the fact Turkey's new first lady wears the Islamic headscarf.
Covered women are currently banned from all state institutions and all universities. The scarf is seen as a symbol of political Islam.
Like the military, Hayrunnisa Gul was also notable by her absence at Tuesday's ceremonies.
But a poll published this week showed that 73% of Turks have no problem accepting a first lady who wears a headscarf.
With a bright pink scarf pinned tightly about her face, Eda Ataoglu is one of them. She had to uncover her head to get an education and she is fed up with claims her headscarf is a subversive symbol.
"We want to work in state offices like uncovered women can. But we can't even go to university in our headscarves," Eda complains.
"This problem has to be solved. Having a first lady like Mrs Gul is a real honour for us. It's a great feeling."
In his acceptance speech Abdullah Gul described secularism as a model that underpins freedom for different lifestyles. That is seen as a signal he would support efforts to relax the rules on the headscarf.
Whilst such a move would have the support of many Turks, most believe the AKP will tread with caution on this and other sensitive issues - at least initially.
"The secularists see the election of Abdullah Gul to the presidency as a more serious danger than the AKP receiving 47% of the votes," Mehmet Ali Birand wrote in Wednesday's Posta newspaper.
"They believe Turkey will become more and more religious, and they're angry. But Abdullah Gul himself can prevent this escalation. You will see that with his general attitude, and by remaining non-partisan, he will ease this transition period."
Mr Gul has already pledged to be a president to all Turks. But the balance of power has shifted here.
Just six years after it was founded, the AKP has won control of parliament, the government and now the presidency.
The military remains on its guard. The AK Party is celebrating what it calls the triumph of democracy.