By Aziz El Yaakoubi

RABAT (Reuters) - Tensions have erupted between Morocco's royal establishment and the Islamist ruling party, with the Islamist justice minister complaining of "weird" goings-on in the run-up to a parliamentary election next month.

Mustapha Ramid accused his government colleague Mohammed Hassad, a technocrat appointed by the royal palace as interior minister, of monopolizing decisions on organizing the election and failing to consult with the justice ministry.

Unlike rulers in Tunisia, Egypt and Libya who were overthrown in Arab Spring revolutions in 2011, Morocco's King Mohamed rode out popular protests while ceding some authority to the government, which has been led for the past five years by the Islamist Justice and Development Party (PJD).

But the coming election is straining the delicate political balance in the country of 34 million people by exacerbating divisions between the palace and the PJD.

"The justice minister used to decide with the interior minister on all election matters but now, three weeks before Oct. 7 elections, weird and strange things are happening, " Ramid said on Facebook, without going into details.

Last week, the interior ministry rejected the application of a conservative cleric allied to the PJD who wanted to run as an election candidate in the tourist city of Marrakesh, with officials accusing him of making hate speeches. The PJD dismissed the charge, but replaced him with another candidate.

Last week the king accused a minister from the PJD's junior partner of dragging the monarchy into the campaign by describing a royal adviser as an incarnation of authoritarianism.

On Sunday, hundreds of people demonstrated in the city of Casablanca against what they called the "Islamisation of society". The PJD said the protest was supported by organizations that should be neutral in politics, a veiled accusation against the interior ministry.

CORRUPTION CAMPAIGN

Justice minister Ramid said that because of his alleged exclusion from decisions on the running of the election, he could not be held responsible for any "errors, deviation or excess."

Hassad, the interior minister, played down his colleague's accusations and said he had contacted Ramid since the Facebook posting "in order to stay mobilized to carry out the mission that His Majesty has entrusted to us".

He denied any involvement by his ministry in the Casablanca demonstration.

The king still holds ultimate power under the constitution of the North African country. The elections will be only the second since his reforms, and the PJD is looking to solidify its position after running a campaign stressing its commitment to fight corruption.

The royal establishment and its political supporters are distrustful of the Islamists. The PJD and its junior ally have accused the establishment of favoring their main rival, the Authenticity and Modernity Party (PAM), whose founder is now a palace adviser. The palace says the king maintains the same distance from all political parties.

The PJD, which does not openly challenge the king's authority, made gains in local elections last year to control the capital Rabat and other major cities, where its anti-corruption drive struck a chord with voters.

"It is the worst confrontation between the regime and the PJD since 2011," said Issandr El Amrani, North Africa project director at International Crisis Group. "I don't think this confrontation will continue after the election; what we are seeing are warning shots as the elections approach."

(Editing by Patrick Markey and Mark Trevelyan)