SINCE making gains in municipal elections last year, things have gone downhill for Morocco’s ruling Justice and Development Party (PJD). First, a former candidate was accused of sexual harassment. Then in July a party member was arrested with three tonnes of cannabis. One of its governors is accused of trying to influence a big property deal. And in August two sexagenarian leaders of the party’s religious wing, one married, were caught by police in a “sexual position” on a beach.

This would be bad for any party, but the PJD is Islamist and its members are prone to moralising. So some Moroccans have revelled in its misfortune, especially as it comes in the run-up to parliamentary elections on October 7th. Over 30 parties will compete for 395 seats, but the real battle is between the PJD and the Party for Authenticity and Modernity (PAM), which vows to “liberate” Morocco from the Islamists. The PAM won about the same number of votes as the PJD in the municipal polls.

These are the second parliamentary elections since thousands of Moroccans took to the streets in 2011 demanding curbs on the near-absolute monarchy. That year King Muhammad VI ceded some of his power to parliament and the people, and thereby avoided the worst of the Arab spring. But many people think the royal palace is now conspiring against the PJD in favour of the PAM. The latter’s founder is now a royal adviser. “Weird and strange things are happening,” wrote Mustapha Ramid, the PJD’s justice minister, on Facebook this month.

On September 18th hundreds gathered in Casablanca, the commercial capital, ostensibly for a rally against “Islamisation”. But when questioned, some protesters said they did not know the meaning of the word. The PJD suspects that the PAM was behind the event, egged on by the interior ministry, which is led by a royal appointee. A week earlier the ministry rejected the candidacy of a conservative cleric from Marrakech allied to the PJD. Many Moroccans also question the party’s recent troubles. “Those ‘scandals’ were used to disqualify the PJD,” says Muhammad Sammouni, who will vote for a third party. “The police reports that should have been secret were given to certain press and published.”

On the issues, the PJD rightly argues that it has made tough decisions to put the country’s finances in order. These include cutting subsidies, reforming the pension system for public servants and freezing government hiring. As a result, the country’s fiscal deficit dropped from 7.3% of GDP in 2012 to 4.3 % last year. Low oil prices have helped Morocco cut its current-account deficit, too. Analysts are generally bullish on the country’s prospects.

But a drought has hit the economy hard and unemployment remains stubbornly high. “The executive of the PJD promised a growth rate of 7%,” says Samir Aboulkacim of the PAM. “We ended up with 1.5%.” The PJD’s promise to root out corruption, a centrepiece of its last campaign, has gone largely unfulfilled. Forces close to the king still control key sectors of the economy. The PAM, for its part, promises to lower state debt and create 150,000 jobs per year.

While the economy is voters’ main concern, some fear that Morocco’s movement towards a more democratic system—and a more constrained monarchy—is faltering. “The big issue here is to respect the will of the Moroccan voters and not to go back to the days where the results were cooked by the regime,” says Najib Chaouki, a journalist. He believes the PJD would win free and fair elections. But even it does not challenge the authority of the king.