An AFP journalist outside Mornaguia prison near Tunis saw throngs of the media mogul's supporters waving Tunisia's red-and-white flag and Karoui campaign banners as they jubilantly cheered for him.

An elated Karoui then left the scene in a black Mercedes, and drove off without speaking to the press.

The release, which came hours ahead of final results from parliamentary polls, is the latest twist in a shock election dominated by political outsiders in the country whose 2011 revolution sparked the Arab Spring regional uprisings.

The Court of Cassation's decision to release Karoui, a business tycoon who has been detained since August over a money laundering probe, also comes ahead of Sunday's final presidential vote.

The results from last week's parliamentary poll are expected to reap a legislature riven by divisions, with Islamist-inspired Ennahda likely to win the largest number of seats, but still falling far short of a majority.

Karoui's lawyer Kamel Ben Messoud earlier said the court had "annulled the detention order" against his client.

Another of his lawyers, Nazih Souei, said Karoui remains under investigation, "but he is free".

A tired electorate

Karoui is running against conservative law professor Kais Saied on Sunday in the second round of voting.

Saied had announced last weekend he was quitting campaigning in order to avoid an unfair advantage over Karoui.

The sidelining of Tunisia's post-Arab Spring political class in the September 15 presidential first round was rooted in frustration over a stagnant economy, high unemployment, failing public services and rising prices.

While it has succeeded in curbing jihadist attacks that rocked the key tourist sector in 2015, Tunisia's economy remains hampered by austere International Monetary Fund-backed reforms.

With the electorate tired of political manoeuvring and the failure to improve living conditions since the ouster of late longtime autocrat Zine El Abidine Ben Ali, political newcomers Karoui and Saeid have taken the lead.

Campaigning by proxy

Previous requests to release Karoui had been turned down and he has branded his arrest as "political".

Despite being behind bars, he won 15.6 percent of votes in the first round of the presidential poll.

The party he founded six months ago, Qalb Tounes (Heart of Tunisia) appears set to come second behind Ennahda in the parliamentary poll.

To date, Karoui had been forced to campaign by proxy -- through his wife and the Nessma TV channel he founded.

And while his release comes as a surprise, it remains uncertain what impact it will have on his bid for the presidency.