Veteran anti-Islamist politician Beji Caid Essebsi was declared the winner of Tunisia's first free presidential election on Monday, capping off the transition to democracy in the birthplace of the Arab Spring.
But in a sign of the challenges ahead, police fired tear gas to disperse hundreds of youths who burned tyres in protest at the result.
Essebsi, an 88-year-old former official in previous Tunisian regimes, took 55.68 percent of the vote to defeat incumbent Moncef Marzouki in Sunday's run-off, the electoral commission said.
Essebsi had claimed victory shortly after polls closed but Marzouki, a long-exiled 69-year-old rights activist, refused initially to concede defeat.
On Monday, however, Marzouki's spokesman said on Facebook the outgoing president had congratulated his rival.
A first round of voting on November 23 had seen Essebsi in the lead with 39 percent of the vote, six points ahead of Marzouki.
Participation in the second round was 60.1 percent, electoral commission chief Chafik Sarsar said, after authorities had urged a high turnout.
US President Barack Obama congratulated Essebsi and hailed the vote as "a vital step toward the completion of Tunisia's momentous transition to democracy", a White House statement said.
Obama's secretary of state, John Kerry, said: "Tunisia has provided a shining example to the region and the world of what can be achieved through dedication to democracy, consensus, and an inclusive political process."
The vote was seen as a landmark in Tunisia, which sparked the Arab Spring mass revolutions with the 2011 ouster of longtime strongman Zine El Abidine Ben Ali.
However, the campaign was bitter and divisive, with Marzouki insisting a win for Essebsi would mark the return of Tunisia's old guard of ruling elites.
Essebsi in turn accused his rival of representing the moderately Islamist party Ennahda that ruled Tunisia after the revolution and which installed him as president.
Continued divisions were clear as some 300-400 protesters clashed with police in El Hamma in the south, where Marzouki had widespread support.
Protesters "set fire to tyres and tried to attack a police station by throwing stones. Security forces responded with tear gas," interior ministry spokesman Mohamed Ali Aroui said.
Several police were wounded in the clashes, which began late on Sunday, Aroui said.
After declaring victory on Sunday, Essebsi had urged Marzouki to "work together for the future of Tunisia".
The vote was the first time Tunisians have freely elected their president since independence from France in 1956.
French Foreign Minister Laurent Fabius on Monday congratulated the country on its "milestone" vote.
"The successful staging of this presidential election confirms Tunisia's historic role," he said in a statement.
President Abdelaziz Bouteflika in neighbouring Algeria also congratulated Essebsi and the "maturity" of the Tunisian electorate.
The weekly Tunis Hebdo said the vote would "enhance Tunisia's reputation as the only Arab Spring country that has managed to survive".
The revolution that began in Tunisia spread to many parts of the Arab world, with mass protests in Egypt, Libya, Syria and Yemen.
In every country except Tunisia the revolution was followed by violent turmoil or, as in Syria's case, a devastating civil war.
Sunday's vote was largely peaceful, though troops guarding ballot papers in the central region of Kairouan who came under attack shot dead one assailant and captured three, the defence ministry said.
The authorities had deployed tens of thousands of soldiers and police for polling day.
Ahead of the vote, jihadists had issued a videotaped threat against Tunisia's political establishment.
Essebsi's Nidaa Tounes party won parliamentary polls in October and he promised to begin the process of forming a government after the presidential vote.
Under a new post-revolution constitution, the powers of the president have been curbed to guard against a return to dictatorship.
Ennahda came second in the general election and has not ruled out joining in a governing coalition.
The next government will face major challenges.
Tunisia's economy is struggling to recover from the upheaval of the revolution and there are fears that widespread joblessness will cause social unrest.
A nascent jihadist threat has also emerged, with militant groups long suppressed under Ben Ali carrying out several attacks including the killings of two anti-Islamist politicians.