Beji Caid Essebsi (centre), leader of Tunisia's secular Nidaa Tounes party and a presidential candidate, gestures after casting his vote at a polling station in Tunis on Sunday.

AFP/Tunis

Tunisians voted on Sunday in the runoff of the first free presidential election in the country's history, the final leg of an at times bumpy four-year transition from dictatorship.

The second round vote pits 88-year-old favourite Beji Caid Essebsi, leader of the anti-Islamist Nidaa Tounes party, against incumbent Moncef Marzouki, who held the post through an alliance with the moderate Islamist movement Ennahda.

Ahead of the landmark vote, which sets Tunisia apart from the turmoil of other Arab Spring countries, jihadists issued a videotaped threat against the North African state's political establishment.

It is the first time that Tunisians have freely elected their president since independence from France in 1956.

Amid tight security and the closure of main border posts with strife-torn neighbour Libya, almost 5.3mn Tunisians were eligible to vote.

Polls opened at 8.00 am and were due to close at 6.00 pm.

The result is due to be announced between Monday and Wednesday.

A first round held on November 23 saw Essebsi win 39% of the vote, six percentage points ahead of Marzouki, a 69-year-old former rights activist installed by parliament two months after December 2011 polls.

The vote is the country's third in as many months, after Nidaa Tounes won an October parliamentary election, making Essebsi favourite to be the next president, but with powers curbed under constitutional amendments to guard against a return to dictatorship.

The campaign was marked by mudslinging, with Essebsi refusing to take part in a debate with Marzouki, claiming his opponent is an "extremist".

Essebsi insists that Marzouki represents the Islamists, charging that they had "ruined" the country since the 2011 revolution which toppled veteran ruler Zine El Abidine Ben Ali and gave birth to the Arab Spring.

Marzouki in turn accused Essebsi, who served as a senior official in previous Tunisian regimes, of wanting to restore the old guard deposed in the revolution.

He even suggested that Essebsi's camp was preparing to "win through fraud", drawing a sharp rebuke from the electoral commission.

The authorities have deployed tens of thousands of troops and police to provide security on polling day.

Troops kill assailant hours before Tunisia vote

Tunisian troops killed a gunman and captured three others on Sunday after they attacked soldiers guarding ballot papers for the country's presidential vote, the defence ministry said.

The pre-dawn attack targeted a school in the central region of Kairouan where the ballot papers had been stored under army guard.

"The vigilance of the soldiers and the swiftness of their response thwarted this operation and led to the death of a man armed with a hunting rifle and the arrest of three suspects," ministry spokesman Belhassan Oueslati told AFP.

One soldier and one suspect suffered minor wounds, he added.