Morocco’s King Mohammed VI appointed a new Islamist-led government on Thursday ending a months-long crisis triggered by the defection of a key coalition partner, a minister told Agence France Presse.

The king “has just appointed the new government” at a ceremony at the palace in Rabat, said Justice Minister Mustafa Ramid, a member of the moderate Islamist Justice and Development Party whose leader, Abdelila Benkirane, remains prime minister.

The cabinet shake-up sees Saad-Eddine El Othmani replaced as foreign minister by Salaheddine Mezouar, who heads the National Rally of Independents and whose agreement to join the government effectively prevented it from collapsing.