Guinea Bissau Prime Minister Baciro Dja said on Wednesday he would resign after the Supreme Court ruled that his appointment by the president last month violated the country’s constitution.

The decision of the eight-judge panel and the resignation threatens to disrupt the West African nation’s efforts to emerge from years of military coups and political instability.

“I will acknowledge the political consequences (from the ruling) by drafting my letter of resignation which I will submit to the head of state,” Dja told journalists.

The court ruled on Wednesday that the decision by President Jose Mario Vaz to appoint Dja by decree last month violated the constitution, because an appointment required consultations with parliamentary parties.

Vaz’s dismissal of the former prime minister, Domingos Simoes Pereira, was rejected by many in the ruling PAIGC party to which both men belong.

The president later named Dja as premier and a cabinet was appointed this week, though the court’s ruling now calls its legitimacy into question.

“The plenary session of the Supreme Court of Justice declares unconstitutional, notably by its form, the presidential decree,” the court said in a declaration distributed to journalists.

“The nomination of the new prime minister, in this case Baciro Dja, is an affront to the constitution of the republic (and) a flagrant violation of election results,” it said. Neither Vaz nor the PAIGC were immediately available to comment.

The dispute between Vaz and Pereira, fed by confusion over the overlapping duties in Guinea Bissau’s semi-presidential system, has worsened since elections last year restored democratic rule after a 2012 army coup. The former Portuguese colony has suffered nine coups or attempted coups since 1980

Demonstrations against Vaz since Pereira’s dismissal have been peaceful and the country’s military has vowed to stay out of the political tug-of-war and obey the constitution.

Pereira helped secure more than 1 billion euros ($1.11 billion) in financing at a March conference to help stimulate the economy. But Portugal said last month political uncertainty could endanger the much-needed assistance.