Nairobi: Kenyan Attorney General Githu Muigai resigned after a six-and-a-half year tenure marked by missteps including changing the country’s electoral law before a disputed presidential vote.

President Uhuru Kenyatta nominated Appeals Court President Paul Kihara Kariuki as Muigai’s replacement, according to a statement on his Twitter account. Kenyatta also moved Solicitor General Njee Muturi into the presidency as deputy chief of staff, and proposed Kennedy Ogeto as his replacement.

Kenyatta’s administration faced a series of legislative setbacks under Muigai’s watch, including having parts of the Security Laws Amendment Act of 2014 declared unconstitutional, and the legality of a Constituency Development Fund challenged in the Supreme Court. In October, Muigai oversaw changes to voting laws that the US and European Union said undermined free elections in Kenya.

“It was just a matter of time” before Muigai left, said Herman Manyora, a political analyst and lecturer at the University of Nairobi. “His performance has been wanting, his advice has been wanting. A lot of unconstitutional laws were passed under his watch.”

Kenyatta’s nominations of Kariuki and Ogeto suggest he’s surrounding himself with loyalists as he seeks to secure his legacy in his final term, Manyora said. His proposals for three new members of the Judicial Services Commission, which recommends the appointment of judges to the president, indicates he may carry out a threat to overhaul the judiciary, the Nairobi-based Star newspaper reported Wednesday.

Kenyatta criticised the judiciary after the Supreme Court annulled a presidential election held in August, labelling the decision a “judicial coup” and calling the judges “crooks” as he pledged to “revisit this agenda” at a later stage. He won a second term in a rerun vote held in October that was boycotted by the opposition.

The main opposition National Super Alliance has refused to accept the outcome of both votes. Last month, the four-party coalition’s leader, Raila Odinga, swore himself in as the country’s so-called people’s president to lead a campaign for fresh elections.

While Muigai had previously warned such a declaration would be treasonous, the state has yet to charge Odinga with any offence. The attorney general’s departure may also have been prompted by the Kenyatta administration’s crackdown on the opposition following the mock inauguration, said Patrick Gathara, an independent political analyst in Nairobi.

The state shut down transmissions by three private television stations for broadcasting the ceremony, deported an opposition-supporting Kenyan lawyer who has Canadian citizenship, charged a lawmaker with presiding over the mock inauguration, and threatened to withdraw the passport of several senior alliance members. The authorities ignored court orders to reopen the television channels and to present the Kenyan lawyer before a judge.

“Muigai was somewhat uncomfortable with the more egregious bits of Kenyatta’s undemocratic behaviour,” said Gathara. “One could speculate that the latest crackdown and wholesale trashing of court orders may have been the last straw, but I think that would be generous. He really was not averse to turning a blind eye to the abuse of law by government.”

Muigai didn’t answer two calls to his mobile phone seeking comment.

— Bloomberg