On October 6, as the sun was setting behind the monumental 13th-century gate of the old city of Sale, the Party of Justice and Development was organizing its last rally for Morocco’s parliamentary elections. Sale lies across the Bou Regreg River from Rabat; it is the capital city’s less affluent twin, and a stronghold of the PJD, an Islamist party that has headed the country’s government for the last five years. “Say ‘Inshallah!’” yelled a man tasked with warming up the crowd, clapping his hands above his head while a catchy pop song extolling the party and its struggles blared from loudspeakers. On the esplanade in front of the gate, several thousand supporters seated on rows of white chairs were diligently waving flags with the party’s logo, a lamp. Veiled women snapped selfies.

Morocco’s last parliamentary elections were held in 2011, when, just like Tunisians, Egyptians, and others in the region, people took to the streets demanding more democracy and less corruption in a series of demonstrations dubbed the February 20 movement. King Mohammed VI responded quickly to the protests by raising salaries and promising a more liberal constitution. The PJD supported the king and was allowed to compete freely for Parliament, winning the greatest number of seats.

After that, Morocco took neither the Tunisian nor the Egyptian route: It didn’t move any closer to democracy, and it didn’t slide into strife and chaos. Alongside the oil-rich emirates of the Gulf and the kingdoms of Jordan, Saudi Arabia, and Qatar, it’s one of the few countries in the region to have passed through the Arab Spring and its aftermath largely unscathed. Morocco is a quiet place, often overlooked in a region marked by turmoil. Today this stability is intriguing to many, who wonder: Is it the product of lucky circumstances, a sign of exceptionalism, or a mirage? The kingdom’s political system has proven remarkably adept at containing and negotiating demands for change—but for how long?

The 2011 Constitution did little to change the balance of power among Morocco’s branches of government, with the monarchy far outweighing the rest. And the Islamists’ entente with the palace has been an uneasy one. Across the region, the crushing of popular uprisings has led to deeper authoritarianism and the rise of jihadism. In a polarized landscape, the tide has now turned against Islamist parties and political compromise. People here mention “the Egyptian temptation,” referring to the military coup that ended the Muslim Brotherhood’s tenure in Cairo in 2013. In the run-up to Morocco’s election, the largely anti-Islamist press conducted a relentless campaign against the PJD, uncovering an extramarital affair between two leaders of its social movement and accusing the group of accepting money from Qatar.

When the PJD’s leader, Prime Minister Abdelilah Benkirane, took the stage in Sale, he denounced the “below the belt” attacks on his party and spoke of “men of power” who try to buy or intimidate voters. “Thank God the country has changed,” he added; now the people are the ones who decide. He defended his party’s record of the last five years, when it pushed through necessary but unpopular economic reforms, but admitted that it had largely failed to rein in the pervasive corruption or improve the quality of public services. Benkirane promised to do better if returned to power, to deliver “decent schools, hospitals, courts” and to make the average citizen feel “this is his country.” The banner beneath the stage exhorted voters to give the PJD “a chance to continue reform.”

Benkirane is a stocky man with a guttural voice and close-cropped gray hair and beard. Morocco’s most influential politician, he combines traditional paternalism with a brash populist touch, delighting his audience with jokes and asides in Moroccan dialect. His demeanor is jovial but can quickly turn combative. In Parliament, he is famous for speeches in which he chides, provokes, and insults his opponents; the acrimonious exchanges that follow have caused the suspension of several sessions. Benkirane has called his opponents “bandits” and even suggested that some are financed by drug dealers.

Although he comes from a well-off family of traditional religious scholars, Benkirane plays up his modest lifestyle, telling his constituents that he and his wife needed both their salaries in order to afford recent home renovations. His opponents dismiss such talk as cheap populism, but to many Moroccans, who hold political parties in low esteem, the PJD’s everyman image and reputation for honesty is a big draw. “They didn’t get much done,” says N., a middle-aged driver I know who supports the Islamists, “but they didn’t steal.”

On October 7, the PJD ended up winning 125 of 395 parliamentary seats, which means that Benkirane will most likely serve another term as prime minister. But will probity be enough for the Islamists to preserve their popularity? Moroccans are pleased to be a regional exception, but the comparison to North Africa’s failed states sets a low bar; many here argue that their model should be their northern neighbor, Spain. At the same time, the underlying discontent remains strong: A 2013 survey showed that 82 percent of Moroccans believe the state is corrupt, and 91 percent say personal connections are the key to finding employment.

The PJD has promised to deliver change without upsetting the system. In the lead-up to the election, the Islamists and their allies railed against tahakkum (“arbitrary power”)—a code word for the parallel state run by those close to the king who monopolize influence and economic advantage. But whenever the PJD’s candidates mentioned the king himself, it was only to profess their loyalty.

* * *

The PJD’s great rival in this election was the Party of Authenticity and Modernity. The PAM was founded in 2008 by Fouad Ali El Himma, a childhood friend and councillor of the king’s and a major power broker. The Moroccan monarchy has a history of creating ostensibly independent parties that represent its interests and balance out any other rising political force. The PAM has had a meteoric ascent, performing well in rural areas, where voters can reportedly be instructed or bribed by local bigwigs to vote along family, regional, or tribal lines. Its official program is both economically and socially liberal, but its avowed raison d’être is to limit the influence of Islamists.

The PJD argues that the divide that counts in Morocco is not between Islamists and non-Islamists, but between democrats and authoritarians. Others agree, but believe that neither the Islamists nor their opponents stand for true democracy. During the election campaign, Nabila Mounib, the head of a small coalition of leftist parties, emerged as a charismatic representative of a possible “third way.” When I met her on election night at the headquarters of the Federation of the Democratic Left, she was dismissive of both the PJD and the PAM. “How can he declare himself a democrat today?” Mounib said of Benkirane. “He has never called for constitutional or political reforms, nor for democracy by its true name in Morocco—a parliamentary monarchy. He says, like everyone else, that Morocco is in a democratic transition. But the transition has lasted too long and is an eternal transition.”

The parliamentary monarchy that Mounib envisions would entail greater power for Parliament at the expense of the king, who appoints the heads of strategic ministries and government agencies, and whose councillors have greater de facto power than most elected officials. Without a change in the balance of power, Mounib argues, there is no chance for real reforms.

It was easy to see why Mounib, a tall, elegant professor of endocrinology, had captivated the hopes of Morocco’s beleaguered left and the remnants of the February 20 movement. The first woman to be elected head of a political party in the country, Mounib isn’t afraid to speak her mind. She didn’t mince words regarding the PAM, calling it “a total regression,” something that everyone has seen before: “parties that are connected to the makhzen, that have no independence, and that are there so that nothing changes.” Makhzen means “warehouse” in Arabic and is a key term in Moroccan politics. In precolonial times, the sultan’s army would set out from bled al-makhzen (“the land of the warehouse,” where the sultan stored treasure and wheat) to collect tribute from tribes in bled al-siba (“the land of dissent”). The makhzen isn’t the monarchy; it’s a network of patronage and influence in public administration and business that revolves around the king. It has even spawned a verb: Moroccans speak of “makhzen-ization.”

The PAM, Mounib continued, is “not modernist, is not democratic, has no intention of fighting corruption.” Instead, it is a vehicle for currying favor with the monarchy, “an umbrella” for those with illegal or corrupt business dealings. But despite her avid Facebook following among young urban progressives, and despite an open letter from 100 of the country’s leading intellectuals calling her candidacy the best hope for “a real democratic transition and a real economic take-off,” Mounib didn’t win her race. The PAM, meanwhile, gained 102 seats. Turnout was low, especially among the young. With no alternative in sight, the political scene remains nearly deadlocked between Islamists and their opponents.

* * *

This is by design, according to Fouad Abdelmoumni, a veteran left-wing activist. “The palace believes that there should not exist any autonomous, powerful, credible political force,” he told me. “It’s the problem of the monarchy in Morocco: Either it withdraws from the political game…or it becomes more and more aggressive in manipulating the political scene.”

Unlike Arab republics such as Algeria and Egypt, Morocco never experienced a violent rupture with colonialism or a popular revolution. Instead, the forces of traditionalism have prevailed, thanks in no small part to the monarchy, which is widely seen as the guarantor of the country’s unity and stability. But its predominance can only be maintained by keeping political parties weak, fragmented, and subservient.

The Alaouite dynasty has ruled Morocco since the second half of the 17th century, tracing its descent from the Prophet Muhammad through his daughter, Fatima Zohra. During the French protectorate, Sultan Mohammed V supported the movement for independence. When he was deposed by the French and exiled to Corsica and then Madagascar, unrest broke out: Many claimed that they could see the exiled ruler’s face in the moon. Mohammed V returned in triumph to rule the country in 1955, and negotiated its independence from France the following year.

Hassan II, his son, took power after Mohammed V died unexpectedly in 1961, and left his own indelible stamp on the country. Quick-witted, strong-willed, and dedicated to safeguarding the monarchy’s absolute power, Hassan II survived two military coups (“I’m even more king today than I was yesterday,” he told journalists after one) and successfully repressed all nationalist and leftist opposition. From the 1960s through the ’80s, the country’s “years of lead,” thousands were killed, imprisoned, tortured, exiled, or disappeared. In his book Le Maroc et Hassan II, un témoignage (Morocco and Hassan II: A Testimony), historian Abdallah Laroui describes the regime in the 1960s as “a system that every day added a new nail to the coffin of our hopes.” The king “sought less to raise men than to train them, less to educate them than to teach them to resign themselves.”

Fouad Abdelmoumni came of age in those turbulent years. By his mid-20s, he had already served two prison terms for his outspokenness and his activism in leftist student movements. Trained as an economist, Abdelmoumni is now a pillar of Moroccan civil society who has worked with NGOs that disburse microcredits and track corruption. Today, he said, the Moroccan regime’s “capacity to dominate by repression, corruption, and the monopoly of information has frayed,” but the country’s political class is still “emasculated.”

Morocco’s leftist parties have been in decline since Hassan II’s repression in the ’60s and ’70s. When the king finally brought them into government in the 1990s, the parties lost their remaining credibility by participating in a deeply compromised system. “It will take at least another decade for us to have an adult political class,” Abdelmoumni said. “We exited childhood when we were under the monarchy’s paternalism; we are in adolescence.”

* * *

The current king, Mohammed VI, assumed the throne in 1999 amid hopes for a new reformist era. He fired his father’s infamous minister of the interior and created a truth and reconciliation commission. Torture is no longer systemic in the prisons, and the elections are no longer rigged. Illiteracy has declined (though it still stands at just over 30 percent), while services like electricity, roads, and running water have been extended to once-isolated rural areas.

But the monarchy remains the country’s preeminent political arbiter and economic and religious authority. Its power is pervasive, opaque, and, critics say, unaccountable. In 2015, Mohammed VI was ranked by Forbes as the fifth-richest man in Africa, with a fortune of $5.7 billion. He is the largest landowner in the country, and criticizing or speaking of him disrespectfully is a crime.

The king’s personal notice or intervention can instantly right wrongs, change policies, launch businesses or construction sites, and trigger prosecutions. Moroccans know this and go to desperate lengths to deliver messages to him. Last winter, an 18-year-old girl was seriously injured when she tried to intercept the king’s car with a letter begging for assistance and was hit instead. The palace covered her hospital bills.

Mohammed VI’s reign has been marked by big infrastructure projects: a vast new commercial port in Tangier, expanses of solar panels in the southern desert, a planned high-speed rail line. The valley between Rabat and Sale is rife with bulldozers and cranes: It will be home to a marina, an opera house designed by the starchitect Zaha Hadid, and a skyscraper projected to be the highest in Africa.

Yet the country’s economy is fragile, dependent on remittances from Moroccans abroad, on tourism, on international investments and loans, and on the weather (agriculture is a key sector, and a year of scarce rain can depress GDP growth by several points). The social inequalities remain staggering. Poverty and illiteracy are concentrated in the rural interior and in urban slums. Despite legislation, child marriage and child labor persist, and Morocco has one of the lowest-ranked education systems in the region.

The 2011 Constitution formally recognized the country’s pluralism, according official status to the indigenous Berber language and expressing a commitment to protecting human rights and individual freedoms. But the press has nonetheless been muzzled, and critics of the system, from rappers to university professors, have been taken to court. The Moroccan Association for Human Rights, the country’s leading human-rights organization, has been harassed and systematically prevented from holding events and forums. Yet Europe and the United States have turned a blind eye: They’re obsessed with immigration and terrorism, and the Moroccan government is an important ally in containing both.

On a Friday afternoon a week before the election, as crowds of men in their traditional djellabas left a mosque, street vendors were setting up stalls along the sidewalks in the Casablanca neighborhood of Sidi Moumen. I saw no campaign flyers or posters. The piles of rubbish at many corners belied the fact that the area has improved immensely in the last 14 years. That’s when it became infamous as a sprawling shantytown, home to hundreds of thousands of people hidden behind the walls along the highway between Casablanca and Rabat, the country’s economic and political capitals. Today, the shacks have been replaced by rows of apartment buildings; a new tram line gleams in the afternoon sun.

The area had been home to 12 of the 14 young suicide bombers who carried out the 2003 Casablanca bombings, the deadliest in the country’s history. The attacks targeted a hotel, a Jewish cemetery, a Jewish community center (which was empty), and a Spanish cultural center, killing 41 people. In the aftermath, the author Mahi Binebine visited the area repeatedly and interviewed the families of the bombers. His 2010 novel Les étoiles de Sidi Moumen (available in English as Horses of God) is narrated from the point of view of one of the dead terrorists. In the novel, as well as the film adaptation by Moroccan director Nabil Ayyouch, the boys’ radicalization is presented as the outcome of an upbringing steeped in daily brutality and humiliation. The young men have no education and no prospects; they can rely only on each other, and spend their days making ends meet, dealing with corrupt cops and unfair bosses, and hunting for small moments of pleasure.

“The kids I met—it was me when I was young,” Binebine told me. “I didn’t see them as monsters; they are victims. The monster is the state that lets people live like this, in this grime, without education. The religious mafia is monstrous. The rich people in Casablanca, some of them are monstrous.”

In Les étoiles de Sidi Moumen, Binebine imagines the appeal of the environment offered by Islamists, who teach martial arts as well as the Quran. “Sometimes Abou Zoubeir would join us,” recounts the narrator, speaking of the sheikh who slowly radicalizes the boys. “And it was like a victory over the mediocrity of our little lives…. He had given us back our pride through simple words, winged words that carried us as far away as our imagination. We were no longer parasites, human scum, zeroes. We were clean and dignified and our aspirations found resonance in healthy souls. We were listened to, guided. Logic had replaced blows. We opened the door to God and He entered us.”

The 2003 attacks shocked the country, which prides itself on being a bastion of moderate Islam in the region. Morocco has a liberal, largely French-educated elite; the government’s reform of the family code in 2004 significantly strengthened women’s rights. The king, as “Commander of the Faithful,” has the authority to rein in religious extremists. Morocco hasn’t experienced a serious attack since 2003, but according to the Ministry of the Interior, 38 suspected terrorist cells, many of them inspired by or linked to the Islamic State (ISIS), have been dismantled since the beginning of 2013.

The PJD’s critics insist that it has plans to entrench itself in power and to “Islamize” society. The party’s ideology is socially conservative rather than radical: Its minister of communication has proposed that TV stations broadcast the five daily calls to prayer and run more religious programming. In Marrakech, the party chose a Salafist preacher to head its electoral list; the authorities disqualified him for holding “extremist” views. While small groups of progressives have suggested repealing the laws that criminalize homosexuality and eating in public during Ramadan, the PJD comes down squarely on the side of limiting personal freedoms in the name of Islamic values.

* * *

Like many Arab liberals, Binebine doesn’t make much of a distinction between violent extremists and Islamists who run for election. He views them as sharing the same values, and he resents the way they claim a monopoly on religion. He also faces a conundrum. On the one hand, he blames a lack of democracy for the rise of the Islamists: “All the dictators we’ve had in the Arab world have created a vacuum around them, destroyed all democratic alternatives to their power. They laid out the red carpet for the Islamists.” But concerned by their electoral gains, he is also relieved by the limitations that the current system has in place: “We manage to play the game, to manage the situation. In any case,” Binebine adds, “here it’s the king who is boss, not the prime minister.”

Most Moroccans wouldn’t have it any other way. The question is whether this system can respond to the demands for development, opportunity, and fairness that, even in a country with no appetite for radical change, simmer below the surface.

As Nabila Mounib campaigned in Morocco’s interior, what struck her most, she told me, were the “enormous expectations in terms of public services.” People spoke about schools, health, and access to water; they complained about corruption, the lack of job opportunities, and abuses of power. But she was also surprised by their “rather deep political consciousness. They live day to day, but they see far in terms of where their country is headed. They know they are lacking things and that others are lacking things. They aspire to something better.”

Sometimes, they lose their patience. In the small southern town of Sidi Bibi, officials reportedly let locals build homes illegally before the election, hoping to win their votes. But after the election, the authorities came to demolish the new homes. The move provoked resistance. A protest march of several hundred people degenerated into a riot after being attacked by police. According to reports in the Moroccan media, the people set fire to vehicles, shops, banks, and one public building; they cut off the road and encircled local administration buildings.

Abdelmoumni believes the country is socially and economically fragile, but he takes the long view. “A generation ago, we were suffocating,” he stressed. “Having lived through both periods, I’m happy at where we are; the gains are very important relative to what I lived, and the hopes are even greater. I prefer a slow evolution to a conflagration that could be bloody and uncertain.” Moroccans today have higher expectations, but they have little appetite for risking the unknown. “When people saw authoritarian regimes falling with hardly a drop of blood, it was tempting,” Abdelmoumni said. “When we saw what happened in Bahrain, Yemen, Libya, and Syria, we started saying, ‘OK, we want change, but not at any price.’”

That balance can be suddenly tested. In late October, as Morocco’s political parties negotiated to form a new government, a policeman confiscated the merchandise of a fish vendor in the town of Al Hoceima: Mouhcine Fikri was selling swordfish, a protected catch, out of season. Fikri jumped into a trash compactor to recover the seized fish and was killed. A Moroccan struggling to make a living, arbitrarily targeted by agents of authority and disposed of like trash: Fikri’s death could not have been more dangerously symbolic. News and pictures of the grisly incident traveled instantly and led to demonstrations across Morocco, in which crowds chanted against the makhzen and the state’s hogra (“humiliation”) of citizens. The authorities brought charges against 11 people, including five public officials. Fikri’s family in Al Hoceima say they are waiting for justice.