Israeli voters have spoken, and though neither main faction won a majority, it’s also likely that Prime Minister Benjamin Netanyahu will hold onto power for the immediate future. But most outsiders, especially US Democrats and the lefty foreign-policy establishment, completely miss the ­lesson of these recent elections.

Though most of the world tends to think the only thing worth discussing about Israel is what it should do about the Palestinians, the country’s voters largely ignored that issue and treated the elections as a referendum on their embattled prime minister and his lackluster rival, retired Gen. Benny Gantz.

That’s because there is a consensus about the peace process and the lack of a Palestinian partner that stretches across the Israeli political spectrum — from the moderate left to the right. While Israelis were once deeply ­divided about the peace process, that stopped being true almost 20 years ago.

Neither Netanyahu nor Gantz supports the sort of land-for-peace schemes that once divided ­Israelis. The violence of the Second Intifada shattered their faith in such schemes; the aftermath of the 2005 withdrawal from Gaza, which led to the creation of a Hamas state in that enclave, buried them.

Gantz and his center-left Blue and White Party were determined to portray their stance as no different from that of Netanyahu and just as supportive of the Trump administration’s Middle East plan. Yet somehow this message hasn’t gotten through to the Democratic Party and its candidates. The moderate Joe Biden and the radical Bernie Sanders both seem to think Israelis need to ignore the events of the last 27 years that forged this broad consensus.

Sanders is, of course, the nuttier of the two. His slanderous comments about AIPAC — he falsely framed the pro-Israel lobby as a platform for “bigotry” — made it clear that the US-Israel alliance would be ­another casualty of a Bernie Bros administration.

The problem isn’t just Sanders’ willingness to smear a bipartisan group or to embrace the rabidly anti-Israel Rep. Ilhan Omar (D-Minn.) and other advocates of a Boycott, Divest and Sanction movement drenched in anti-Semitism.

Sanders’ “even-handed” stances — ending the blockade of the Hamas-run Gaza Strip and ­diverting some of the aid the Jewish state receives from the United States to the enclave — are completely divorced from reality.

But Biden is ­almost no better. The ex-veep seems either unaware of or ­unconvinced by the facts that have driven Israeli voters to ­reject the tired, old land-for-peace schemes.

While Biden is supportive of AIPAC, he is also determined to revive his old boss President Barack Obama’s efforts. He advocates a return to policies that would pressure the Israelis to make territorial concessions to Palestinians — who remain as determined as ever to reject the legitimacy of a Jewish state no matter where its borders are drawn.

The premise of the Obama ­administration’s Israel policy was that by creating “daylight” between Washington and the Jewish state, the latter would feel compelled to make concessions that even liberal Israelis now see as the height of folly. It didn’t work, and in the years since, the whole region has dramatically changed.

Obama and Biden’s nuclear deal with the ayatollahs, and their broader failure to check the Iranian regime’s ­hegemonic ambitions on the Middle East, drove the moderate Arabs to forge a hitherto unthinkable partnership with the Jewish state.

The Saudis, the Emiratis and other powers have all downgraded the Palestinian cause. They now view Israel as a crucial bulwark against Tehran. And they’re running out of patience with Palestinian ­intransigence.

All of which means the two-state solution isn’t going anywhere anytime soon.

While such a solution, the theoretical end goal of the Trump plan, is a rational way to end the decades-old conflict, so long as the Palestinians remain committed to the Jewish state’s elimination and to terrorism, pressure on Israel makes no sense. The Arabs get this.

Yet neither of the major Democratic candidates acknowledges this Israeli consensus or understand why it exists.

­Instead of listening to Clinton and Obama administration alumni who are eager to get back to work next year pressuring ­Israel and ignoring Palestinian violence, the Democratic candidates should be listening to ­Israel’s voters and stop trying to repeat the mistakes their party has made in the past.

Jonathan S. Tobin is editor-in-chief of JNS.org. Twitter: @JonathanS_Tobin