Israel's Supreme Court ruled Wednesday that Prime Minister Benjamin Netanyahu may form a new government while under indictment.

The decision clears the way for Netanyahu and his rival, Benny Gantz, to proceed with the formation of their emergency government.

The court also upheld the coalition agreement between Netanyahu and Gantz, which will require new legislation. A group of nonprofit advocacy organizations had challenged the legality of the deal.

Supporters of Prime Minister Benjamin Netanyahu wear a masks amid concerns over the country's coronavirus outbreak during a protest by in front of Israel's Supreme Court in Jerusalem, Sunday, May 3, 2020. Israel's high court heard petitions Sunday that seek to block Prime Minister Benjamin Netanyahu from forming a government because he has been charged with serious crimes. (AP PhotoTsafrir Abayov)

Supporters of Prime Minister Benjamin Netanyahu wear a masks amid concerns over the country's coronavirus outbreak during a protest by in front of Israel's Supreme Court in Jerusalem, Sunday, May 3, 2020. Israel's high court heard petitions Sunday that seek to block Prime Minister Benjamin Netanyahu from forming a government because he has been charged with serious crimes. (AP PhotoTsafrir Abayov)

"We did not find any legal reason to prevent Netanyahu from forming a government,” the court said.

Netanyahu and Gantz declared that they hope to swear in the new government May 13.