TEL AVIV — Benjamin Netanyahu failed to form a ruling coalition late Wednesday night, becoming the first elected prime minister in Israeli history to stumble in forging a working government.

As the clock struck midnight on Netanyahu, the Israeli Parliament voted to dissolve itself, forcing a Sept. 17 election. The vote was 74 to 45 in favor of dismantling the Knesset.

Up until the final moments Wednesday night, Netanyahu seemed to be on the brink of hammering out a deal with ultra-religious parties.

But he couldn't seal the deal amid demands from far-right lawmakers led by Avigdor Lieberman and his Yisrael Beiteinu party on military draft exemptions

Download the NBC News app for breaking news and politics

"We will run an election that is clear in which we will win," Netanyahu said after the vote.

Netanyahu, 69, seemed to be in the clear for a fifth term in April after his conservative Likud party fended off a spirited challenge from centrists led by Benny Gantz.

The Likud and the opposition Blue and White each won 35 Knesset seats, which seemed to be more than enough for Netanyahu, who had counted on far-right backing.

Lieberman's Yisrael Beiteinu party has only five seats but suddenly became kingmakers in the final moments Wednesday night.

Netanyahu's suddenly precarious hold on power was exemplified by the Labour Party claiming it had been offered a role in a Likud coalition. But the center-left opposition said it rejected the offer, though the Likud refused to confirm the unusual offer.