TUNIS — A once obscure law professor is poised to become the next president of Tunisia in a sharp rebuke of the political establishment that has dominated the sole democracy to emerge from the 2011 Arab Spring uprisings, according to exit polls released Sunday night.

The preliminary data showed that Kais Saied, 61, had secured more than 76 percent of the vote to beat Nabil Karoui, a media mogul. Official results were expected as soon as Monday.

On the streets of the capital, Tunisians honked their car horns in celebration. Thousands gathered on Avenue Habib Bourguiba, the epicenter of the 2011 revolution, chanting Saied’s name and waving Tunisian flags. Others chanted, “Nabil, it’s over,” as fireworks erupted over the crowds. 

“I am so happy and proud of our democracy,” said Rania Gnaba, 32, a financial analyst who was draped in a Tunisian flag. “Saied is going to make sure the laws of the Constitution are respected. He’s going to fight against corruption.”

In a region ruled by monarchs, autocrats and family dynasties, Tunisia on Sunday once again showcased its unique position in the Arab world.

Millions headed to the polls to choose between two political outsiders in the runoff of its second-ever presidential elections. In doing so, they showed contempt for the nation’s political establishment for not solving the high unemployment rate, rising prices and lack of opportunities that helped spark the revolution.

A disillusioned population had placed its hopes on two diametrically opposite candidates: Karoui, a multimillionaire TV station owner who campaigned from a prison cell, and Saied, an obscure academic who hardly campaigned and had to borrow money to register as candidate.

“I am fed up with the political system,” said Najwa Sassi, 45, an employee in a pharmaceutical lab who voted for Saied in Tunis’s upscale enclave of Les Berges du Lac. “But I never expected that we would elect a political outsider. This makes me proud of our democracy.”

In some ways, analysts said, this North African nation embraced political trends seen in other countries, where populist movements have toppled the established political parties.

“Electorates are looking to new faces, and sometimes new faces with untested ideas,” said Scott Mastic, a senior official with the International Republican Institute, which with the National Democratic Institute is observing the elections. “And in that sense, the dynamic here in Tunisia is more similar to things we see in Europe than some other places in this region.”

Yet unlike in Europe, where populism has been fueled by anti-migrant sentiment and race- or religion-based politics, both Karoui and Saied vowed to uproot poverty, battle corruption, and build a better government that can provide health care, education and other basic needs. That in itself stands in stark contrast to elections in other parts of the Arab world, which are typically rigged, and where populations have no real voice.

“We Tunisians are angry at the previous president and governments,” Saoussen Attia, 35, who works at a water supply company, said after leaving a polling station. “They failed us. Today, our dinar is collapsing and corruption is everywhere. Young people like me want a Tunisia that looks like the United States or France.”

Saied and Karoui placed first and second in the presidential election last month contested by 26 candidates. The field included moderate Islamists, secularists and even supporters of Tunisia’s late dictator Zine el-Abidine Ben Ali, who was toppled in the revolution and died last month in exile in Saudi Arabia. The election came less than two months after the death of President Beji Caid Essebsi, 92, who was elected in 2014.

The campaigns of both Saied and Karoui were unorthodox. The day before the start of Karoui’s campaign in August, he was arrested on three-year-old allegations of tax fraud and money laundering, charges his supporters say were politically motivated. International observers raised concerns about the timing of his arrest, given that the 56-year-old media mogul was leading in the polls.

Karoui campaigned from prison, portraying himself as a populist champion of the poor and for those neglected by the political establishment. His brash style and business-minded image evoked comparisons to President Trump and former Italian prime minister Silvio Berlusconi. Karoui was released from prison on Wednesday, but the charges against him still stand.

“Karoui has an economic program, and he’s a lot like me,” Attia said. “I don’t believe in the charges against him.”

Saied, in contrast, is not affiliated with a political party. While his competitors put up billboards and staged large rallies with music, he campaigned largely by speaking to voters on their doorsteps.

Tall and solemn, he has drawn the nickname “Robot Man” for his stiff manner. He is considered deeply conservative — he has referred to homosexuality “as an illness and foreign plot.” At the same time, he has appealed to voters by promising a government that will return power to the people.

Many admired him for his decision to run despite lacking financial resources and his command of the law, which stood in contrast to the controversies consuming his rival.

“We don’t want someone who was just released from prison,” said Mohamed Abidi, 40, a lawyer. “Kais Saied connects with the people.”

Saied will immediately face challenges. In last week’s parliamentary elections, the moderate Islamist Ennahda Party won the most seats, but not a majority. Other parties, including Karoui’s fledgling party, have also gained significant numbers of seats, making it potentially difficult to create a government.

“We are looking at a very fractured political reality in the parliament,” Mastic said, speaking before the exit poll results were announced. “It will take a lot of work to form a governing coalition whatever that looks like and whomever is the president.”