Tunisia's Beji Caid Essebsi has claimed victory in the country's first free presidential election, with exit polls suggesting he won 55.5% of the vote.
Supporters of the 88-year-old celebrated in the capital Tunis.
Campaigners for his rival, caretaker President Moncef Marzouki, say the results are too close to call.
Critics say his success marks the return of a discredited establishment but Mr Essebsi says he is a technocrat who will bring stability.
Tunisia was the first country to depose its leader in the Arab Spring and inspired other uprisings in the region.
Official results are still to be announced from the run-off election but one exit poll gave Mr Essebsi 55.5%, with several others showing similar figures.
Tunisia boosted security for the elections and closed border posts with Libya, which has been plagued by unrest.
A group of at least three attackers targeted a polling station near the city of Kairouan on Sunday morning. Security forces say they killed one attacker and arrested three.
Mr Essebsi appeared on local television after polls closed on Sunday, saying, "I dedicate my victory to the martyrs of Tunisia."
"I thank Marzouki, and now we should work together without excluding anyone," he added.
Supporters danced and let off fireworks outside the headquarters of Mr Essebsi's secular-leaning Nidaa Tounes party.
Mr Essebsi held office under both deposed President Zine el-Abedine Ben Ali and Tunisia's first post-independence leader, Habib Bourguiba.
He won the first round of voting last month with 39% of the vote.
He is popular in the wealthy, coastal regions, and based his appeal to voters on stability and experience.
A spokesman for Mr Marzouki said the victory claim was "without foundation".
Mr Marzouki is a 67-year-old human rights activists forced into exile by the Ben Ali government.
He has been interim president since 2011 and is more popular in the conservative, poorer south.
After casting his ballot, Mr Marzouki said Tunisians "should be proud" of themselves "because the interim period has come to a peaceful end".
Mr Marzouki was thought likely to attract support from the moderate Islamist Ennahda party, which has played a key role in Tunisian politics since the Arab Spring but did not field a candidate.
Whoever wins faces restricted powers under a constitution passed earlier this year.
The president will be commander-in-chief of the armed forces but can appoint or sack senior officers only in consultation with the prime minister.
The president will also set foreign policy in consultation with the prime minister, represent the state and ratify treaties.