Several Democratic presidential candidates had harsh words for Benjamin Netanyahu after the Israeli prime minister, just days before the nation's election Tuesday, pledged to annex Jewish settlements in the occupied West Bank if reelected.

Former Texas Rep. Beto O'Rourke slammed Netanyahu as a "racist" who stands in the way of any broad peace deal between Israel and the Palestinians.

"The U.S.-Israel relationship is one of the most important relationships that we have on the planet, and that relationship, if it is to be successful, must transcend partisanship in the United States, and it must be able to transcend a prime minister who is racist as he warns about Arabs coming to the polls, who wants to defy any prospect for peace as he threatens to annex the West Bank and who has sided with a far-right racist party in order to maintain his hold on power," O'Rourke told reporters on the campaign trail in Iowa.

O'Rourke said Netanyahu's campaign promise "will make peace in the long term impossible."

Sen. Bernie Sanders, I-Vt., also criticized Netanyahu for his annexation proposal, telling NBC News that he "hopes he loses his election."

"When election time comes in Israel, he always tries going even further to the right by appealing to racism within Israel, I think it's unfortunate," Sanders said following his own town hall in Malcom, Iowa. "I'm not a great fan of his, and, frankly, I hope he loses his election."

Meanwhile, South Bend, Indiana, Mayor Pete Buttigieg called Netanyahu's pledge a "provocation."

"This provocation is harmful to Israeli, Palestinian, and American interests," Buttigieg tweeted Saturday. "Supporting Israel does not have to mean agreeing with Netanyahu's politics. I don't."

"This calls for a president willing to counsel our ally against abandoning a two-state solution," he added.

The outcry came after Netanyahu on Saturday suggested he would annex Jewish settlements in the West Bank, which most governments — including Democratic and Republican U.S. administrations — have deemed illegally occupied by Israel.

Beto O'Rourke speaks to supporters at a campaign rally at the University of Iowa on April 7, 2019. Scott Olson / Getty Images

The pledge marked a significant policy shift that observers of Israeli politics said appeared aimed at rallying the nationalist vote ahead of Tuesday's election. Middle East peace advocates have said annexation by Israel would effectively end Palestinian hopes for an independent state.

Israel seized the West Bank during the 1967 war with neighboring Egypt, Jordan and Syria, in a move that was not recognized by the international community. The U.S. considered it occupied territory until a State Department human rights report last month removed any reference to the territory being occupied.

The criticism from O’Rourke, Sanders and Buttigieg also marked an effort to create notable policy differences with President Donald Trump, who voiced full-throated support for Israel in a speech to the Republican Jewish Coalition on Saturday and hit the Democratic Party for having "allowed the terrible scorch of anti-Semitism to take root in their party and in their country."

Netanyahu — whom Israel's attorney general has recommended indicting on bribery, fraud and breach of trust in three different cases — has been campaigning on his close relationship with Trump as proof that he's the only Israeli politician who can preserve the relationship with the U.S.