JERUSALEM — The speaker of Israel’s Parliament, Yuli Edelstein, a staunch ally of Prime Minister Benjamin Netanyahu, abruptly resigned on Wednesday rather than comply with a Supreme Court order that would allow lawmakers to choose his successor.

The move will allow Benny Gantz’s opposition Blue and White party and other opponents of Mr. Netanyahu to take control of the legislative process. They have threatened to enact laws that could bar Mr. Netanyahu from a new term in office.

In a parting gift to the embattled prime minister, however, Mr. Edelstein said his resignation as the Knesset speaker would become effective only on Friday, ensuring that anti-Netanyahu lawmakers would have to wait until the coming week to assert their newfound power.

The machinations, which came as hundreds of protesters with black flags demonstrated and shut down traffic outside Parliament, did not end there: Blue and White said that since Mr. Edelstein’s resignation had not taken effect yet, his refusal to allow a vote on a new speaker amounted to contempt of court.