Kenya’s top court ruled Thursday that President Uhuru Kenyatta’s bid to change the constitution was illegal, dealing a blow to him and his allies ahead of key elections in August.

“The president cannot initiate constitutional amendments or changes through popular initiative under article 257 of the constitution,” six of the seven judges overseeing the case at the Supreme Court said, ruling against Kenyatta’s proposal to expand the executive.

But the court left open the possibility for the reforms — popularly known as the Building Bridges Initiative (BBI) — to be instituted by parliament or through other means, so long as the president did not have a hand in the changes.

The reforms would have been the biggest change to Kenya’s political system since the introduction of a new constitution in 2010.

The initiative has left the East African nation’s political elite divided.

Kenyatta had argued that the change would make politics more inclusive and help end repeated cycles of election violence.

Thursday’s decision came after the High Court and Court of Appeal ruled against the proposed amendments last year.

The appeals court even said Kenyatta could be sued in a civil court for launching the process.

But the Supreme Court ruled against this idea.

“Civil proceedings cannot be instituted in any court against the president or the person performing the functions of the office of the president during their tenure of office in respect of anything done or not done under the constitution,” it declared.

BBI’s detractors — including Kenyatta’s estranged deputy William Ruto, who is running for the top job in August — say the plan is a little more than a naked grab for power by a two-term president who cannot run a third time.

The timing of the reforms spurred speculation in recent years that Kenyatta is seeking to remain in power by establishing the post of the prime minister as part of the BBI.