After six months of post-election deadlock, Morocco's King Mohammed VI named a new cabinet on Wednesday led by the main Islamist Justice and Development (PJD) party, which lost a key ministry in negotiations with rivals.

PJD won parliamentary elections in October, but the formation of a government was delayed during negotiations with parties who critics say were too close to royalists uneasy with sharing power with Islamists.

In March, Morocco's new Prime Minister Saad Eddine el-Othmani agreed to form a coalition government with five other parties, something former prime minister Abdelilah Benkirane failed to do, leading to his dismissal.

Under Moroccan law no party can win an outright majority in the 395-seat parliament, making coalition governments a necessity in a system where the king holds ultimate power despite ceding some authority during protests for reforms in 2011.

The new cabinet includes PJD, pro-market parties RNI and UC, conservative MP party, and the socialist parties USFP and PPS. Together they hold 240 seats in the 395-seat House of Representatives, the lower house of parliament.

Several key ministerial portfolios remain unchanged and under the control of the RNI, which clashed with PJD during talks over its insistence on including the USFP in the coalition, the state news agency MAP said. PJD had resisted under Benkirane's leadership.

READ MORE: Morocco's February 20 movement: 'Demands still alive'

Aziz Akhannouch, RNI leader and close friend of the king, remains minister of agriculture and fisheries.

RNI members Mohammed Boussaid and Moulay Hafid Elalamy remain heads of the Ministry of Finance and Economy and Ministry of Trade and Industry, respectively.

But PJD lost its control of the key Ministry of Justice and Public Freedoms, previously led by Mustafa Ramid, who had been critical of the security service's record during his days as a lawyer and human rights activist.

As minister of justice since 2012, Ramid spearheaded a series of reforms after PJD had won elections in 2011 amid protests inspired by the Arab uprisings across the region. He will remain as minister of state in charge of human rights.

Critics have argued that since the 2011 protests, royalists have tried to push back Islamist influence.

Dismissing claims of royal interference, the palace has said the king maintains an equal distance from all parties.