Foreign observers on Tuesday praised Tunisia's landmark "free" elections, after the Islamists conceded defeat in a vote that raised hopes of a peaceful transition in the birthplace of the Arab Spring.
The Islamist Ennahda party, which had steered the North African nation through the aftermath of the 2011 revolution, congratulated its secular rival Nidaa Tounes which it said would be the largest party in parliament.
Ennahda called on its supporters to celebrate "democracy" and hundreds rallied outside its Tunis headquarters despite the defeat.
Tunisia is the "only tree still standing in a devastated forest," its leader Rached Ghannouchi told the crowd, alluding to other countries where the hopes of the Arab Spring uprisings have given way to conflict or renewed repression.
The European Union's observer mission hailed the conduct of Sunday's election, which took place against a backdrop of tight security because of fears of extremist attacks.
"The Tunisian people have reinforced their commitment to democracy with credible and transparent elections that gave Tunisians of all political tendencies a free vote," mission chief Annemie Neyts-Uytterbroeck told a news conference.
- Political horse-trading -
With neither party expected to win an outright majority, the political horse-trading began ahead of the announcement of full results of polls, in which an array of smaller parties also fielded candidates.
Nidaa Tounes leader Beji Caid Essebsi, an 87-year-old veteran of Tunisian politics, vowed to form a coalition with other parties to take the country forward.
"We took the decision in advance that Nidaa Tounes would not govern alone, even if we won an absolute majority," Essebsi told Al-Hiwar Al-Tounsi television.
"We will govern with those closest to us, with the democratic family, so to speak," he said.
During the campaign he did not rule out sharing power with the Islamists if necessary.
"That will depend on the results," he said. "Once the results are final we will think about that question."
Essebsi has also said he would stand in the November 23 presidential election, and is considered to be a front-runner.
Election organisers have until Thursday to announce the outcome. Projections suggest that Nidaa Tounes will win around 80 of the 217 seats in parliament, against around 70 for Ennahda.
Signup to our newsletter and follow us on Facebook and Twitter!
Under Tunisia's electoral system, the party that wins without an outright majority is given a mandate to form a coalition government.
- 'Fair play' -
Ennahda's admission of defeat was in stark contrast to neighbouring Libya, where Islamists led a militia takeover of the capital Tripoli after they were defeated in a June election.
Ghannouchi "congratulates B Sebsi (Essebsi) on his party's win," his daughter Soumaya said on Twitter.
La Presse de Tunisie, the country's main French-language newspaper, congratulated the Islamists on their sense of "fair play".
"That they conceded defeat and congratulated their opponents is comforting and reassuring in a country... still seeking the anchor of democratic traditions," it said.
Even before the election, Ennahda had called for a government of national unity.
Ghannouchi said compromise and consensus were what had spared Tunisia the devastating violence that has shattered other Arab Spring countries like Libya, Syria and Yemen.
"Whoever comes out top, Nidaa or Ennahda, the main thing is that Tunisia needs a government of national unity, a political consensus," he told Hannibal television.
"This is the policy that has saved the country from what other Arab Spring countries are going through."
Ennahda has not put forward its own candidate for the presidential election, keeping its options open over whom it will back.
There had been fears of violence by Islamist militant groups as voters went to the polls, and about 80,000 troops were deployed to provide security.
A policeman and six suspected militants were killed when police besieged then stormed a house in a Tunis suburb late last week.
While Tunisia is seen as a beacon of hope compared with other Arab Spring countries, its transition has been tested by militant attacks and social unrest.
Poverty and unemployment, which were key factors that sparked the 2011 revolt, remain unresolved and the election campaign was fought on the axis of the economy and security.