Beji Caïd Essebsi, who passed away on July 25, will be remembered as a towering figure in Tunisia’s history. He served his country not only as its first democratically elected president, but also in nearly every other significant national position. He was prime minister, speaker of the National Assembly, minister, and ambassador.

Essebsi’s political philosophy was formed under the leadership of his mentor, Tunisia’s first president Habib Bourguiba. However, in his later years Essebsi developed his own approach based on political inclusion and national consensus, which helped secure the country’s transition to democracy after the uprising of 2010–2011. He leaves behind a rich legacy that Tunisians will need to draw upon to preserve the country’s new democracy as it faces the challenges ahead.

I first met Essebsi soon after I arrived in Tunis as the U.S. ambassador in 2012. The heady early days of the uprising were past and the country was beginning to descend into serious political and security crises. At the time Essebsi was no longer in government, having handed over the prime minister’s post to Hamadi Jebali of the Islamist Ennahda party following the 2011 elections. That was the first of Tunisia’s peaceful transfers of power after the uprising. Out of office, Essebsi soon became a harsh critic of the “Troika” government that Jebali led. Among other things, he disapproved of how that government dealt with the attack on the U.S. embassy by radical Salafis in September 2012, which he believed put at risk Tunisia’s long history of good relations with the United States.

With Tunisia in deep crisis, in 2012–2013 Essebsi organized a new party, Nida’ Tounes, intended as a counterweight to Ennahda. It was composed of disparate elements, including some with ties to the former regime of Zine al-Abedin bin Ali, but Essebsi was determined to construct a party committed to democratic ideals. Restoring the previous regime in some guise was never part of his program.

At the same time, Essebsi began an extended series of private meetings with Rashed Ghannouchi, Ennahda’s leader, that defined the contours of Tunisia’s democratic transition. Essebsi and Ghannouchi worked with each other on the basis of mutual respect and agreed on the principles of political inclusion and national consensus that defined that period.

In contrast to political developments in other countries of the region, Essebsi understood the need to permit the participation in Tunisia’s political process of an Islamist party that was committed to democracy. The Essebsi-Ghannouchi dialogue helped cement the compromises that allowed the Constituent Assembly to ratify a new democratic constitution in 2014 and facilitated another peaceful transfer of power from Ennahda and the Troika to a government of independent figures that organized new elections later that year.

Essebsi was elected president in the 2014 elections, and once in power he continued to emphasize the need for inclusion and consensus. But as Nida’ Tounes broke apart, Ennahda emerged as the largest party in the National Assembly and provided essential support for the various governments that served under Essebsi. In his nearly five years as president, Essebsi faced criticism from some for cooperating with Ennahda, and from others for accepting figures associated with the Bin Ali regime. But Essebsi’s cooperation with Ghannouchi and his support for political inclusion of all those committed to democracy strengthened Tunisia and avoided the pitfalls that other countries in the region faced after the Arab Spring.

The strength of Tunisia’s democracy was evident in the days following Essebsi’s death. The transfer of power to the speaker of the National Assembly, Mohammed Nasser, proceeded smoothly in accordance with constitutional procedures. The Independent Electoral Commission also moved quickly to organize accelerated elections for a new president in line with constitutional requirements. Despite the absence of a functioning Constitutional Court, the constitution worked as intended and the country has remained calm.

With elections for a new president and parliament scheduled in the months ahead, Tunisia’s future will be in the hands of Tunisians. Essebsi’s death before the end of his term means the sequence of elections will be reversed, with presidential elections now preceding the parliamentary vote. This will impact some political calculations, but will not fundamentally alter the democratic process.

A more significant challenge is the poorly developed state of Tunisia’s political party system. In founding Nida’ Tounes, Essebsi had hoped that it would move Tunisia toward a more stable two-party system. However, this did not turn out to be the case, as divisions emerged in Nida’ and no single party has yet emerged to rival Ennahda. This may change in the course of the upcoming elections.

This fragmentation of the party system suggests that the new government that comes out of the upcoming elections will again be a coalition of disparate elements. For that reason, the principles of inclusion and consensus fostered by Essebsi will continue to be relevant in guiding the country’s leadership in the period ahead. Forging consensus will be particularly important as a new government deals with the economic difficulties that Tunisia faces. Previous governments put off the long delayed reforms necessary to lift the country out of its pattern of weak and uneven economic growth and endemic corruption. The resulting social pressure represents perhaps the most serious challenge to Tunisia’s stability going forward. In this situation, parties will have to cooperate to solve economic and social problems for the good of the country.

As the U.S. ambassador in Tunis, I often advised Tunisians not to despair about the complications of a democratic transition and pointed to what the United States had also faced in its early days of building a democratic system. I am reminded of the American founding father Benjamin Franklin’s response as he emerged from the Constitutional Convention when asked by citizens in Philadelphia what kind of government the United States would have. “A republic, if you can keep it,” he reportedly replied. A similar thought, I suspect, might have been Essebsi’s parting message to the Tunisian people.