A Tunisian court has released a presidential candidate days before he is due to stand in Sunday's second round of national elections.

A Tunis appeals court annulled the detention order for Nabil Karoui, who was arrested last month on charges of money laundering and tax fraud.

The 56-year-old media mogul was still able to stand for president, and came second in last month's first round.

Critics say Mr Karoui's detention has damaged the election's credibility.

It is Tunisia's second free presidential poll since the 2011 uprising that toppled ex-President Zine al-Abidine Ben Ali and sparked the Arab Spring.

Despite his release late on Wednesday, Mr Karoui is still facing charges – which he denies. No date has been set for a final verdict.

Tunisia's electoral commission has said that if Mr Karoui loses Sunday's election he could appeal the result as he has not been allowed a fair campaign.

Mr Karoui had failed to win previous attempts to be released and began a hunger strike in September to demand his freedom.

He has never held political office. He founded a charity focused on fighting poverty, an issue that has been a central theme of his campaign.

But critics have accused him of using the charity and his TV channel to further his political ambitions.

What happened in the election?

Mr Karoui and another outsider, Kais Saied, saw off a crowded field of 24 other candidates in the first round.

Mr Saied, an independent candidate and law professor, took 18.4% of the vote with Mr Karoui receiving 15.6% of votes cast.

Supporters take pictures with Tunisian presidential candidate Kais Saied
Nabil Karoui will face another political outsider, Kais Saied (C), in a run-off vote

The result marked a blow for Tunisia's political establishment, including for Prime Minister Youssef Chahed and former interim President Moncef Marzouki, who both failed to progress.

The winner on Sunday will be appointed for a five-year term. Tunisia's president has control over defence, foreign policy and national security. The prime minister, chosen by parliament, is responsible for other portfolios.

The election was brought forward after the death in July of the country's first democratically elected president, Beji Caid Essebsi, who took office in 2014.