Hamas has ruled Gaza since 2007, and there is not much in its record to admire. The Islamist party is harsh, narrow-minded and intolerant of dissent. Its charter is anti-Semitic. It fires rockets into Israeli territory and builds tunnels under it to kill or kidnap Israeli soldiers. It knows that the Israeli attacks it provokes will kill hundreds of Palestinian civilians, but does so anyway, knowing that those deaths will garner sympathy around the world.

It is also weaker than it was, because it is losing the military battle against Israel.

By contrast, Israel is the most successful state in the Middle East. It is the region’s only true democracy, a hub of invention, enterprise and creativity. Israel has overwhelming firepower in the fight in Gaza. Most of its people are united behind their soldiers and have the firm backing of America’s Congress.

Though Israel is winning the battle, however, it is struggling in the war for world opinion. That matters in part because Israel is a cosmopolitan trading country that looks to its American ally for security, but also because Israel needs to hear some of what its critics are saying.

A generation ago Israel had the best of the argument with Yasser Arafat’s Palestine Liberation Organization, in many ways a less vile outfit than Hamas. Young Europeans spent their gap years on kibbutzim. The Western world cheered when Israeli commandos rescued Jewish hostages from the terminal building in Uganda’s Entebbe airport in 1976.

As the occupation of Palestinian territory has dragged on, however, sympathy has seeped away. In a poll published in June, before the destruction of Gaza, the citizens of 23 countries put the balance of those who think Israel is a good or bad influence on the world at minus 26 percent, ranking it below Russia and above only North Korea, Pakistan and Iran.

A growing number of Europeans call Israel racist, with the sinister flourish that Israelis, of all people, should know better. Even in America, where a solid majority backs Israel, the share that thinks its actions against the Palestinians are unjustified has risen since 2002 by five percentage points, to 39 percent. Among 18-to-29-year-olds, Israel is backed by only a quarter.

Many Israelis, and their most fervent supporters in Congress, see today’s hostility as the culmination of a long process of demonization, double standards and delegitimization. They have a point.

Holding a country to high standards, as Israel’s critics do, can be a compliment, but against Israel morality is often used as a cudgel. The common slur that Israel is an apartheid state ignores the fact that Israel’s minorities, such as the Druze, Arabs and Bahais, are protected by the country’s independent courts, including the highest, which has a sitting Arab Israeli judge. The “BDS” campaign to impose boycotts, encourage divestment and introduce sanctions calls not only for an end to the occupation of the West Bank and for equal rights, but also for the right of return of all Palestinian refugees — in other words, for the erosion of Israel as a Jewish homeland. Protests in France against the fighting in Gaza have led to attacks on synagogues and Jewish-owned businesses. No wonder that many Israelis feel that the world is against them, and believe that criticism of Israel often is a mask for antipathy toward Jews.

They would be wrong to ignore it entirely, however. That is partly because public opinion matters. For a trading nation built on the idea of liberty, delegitimization is, in the words of an Israeli think tank, “a strategic threat.”

Mostly, though, it is because some of the foreign criticism is right.

That begins with the scale of the violence in Gaza. Some 1,400 Palestinians have died in the past few weeks, compared with 56 Israeli soldiers and four civilians. Even allowing for Hamas’ brutality, no democracy should be happy with a military strategy that results in the death of so many children, let alone the crass claim from Israel’s ambassador to Washington that its soldiers deserve a Nobel Peace Prize. The destruction is driving support toward Hamas and away from the moderate Palestinians who are Israel’s best chance for peace.

More than that, however, Israel needs to hear what its critics say about the need for a two-state solution, which remains the only answer that will work.

Time is not on Israel’s side. Palestinians already may outnumber Israelis in the lands they share. Without two states, Israelis and Palestinians will be left with one that contains them both. The risk for Israel is either of a permanent, non-democratic occupation that disenfranchises Palestinians or of a democracy in which Jews are in a minority. Neither would be the Jewish homeland with equal rights for all that Israel’s founding fathers intended.

Secretary of State John Kerry has made a Herculean effort to forge peace between the Israelis and the Palestinians along the lines of two states for two peoples. When the talks broke down, a few months ago, he blamed Israel’s settler lobby. That outraged right-wing Israelis, and now the left has joined in the derision because he proposed a cease-fire in Gaza that Israelis thought favored Hamas.

Kerry is right, however. If Israel continues to build settlements in the occupied territory, it will gobble up land that should belong to an independent Palestinian state, making peace harder to reach.

The same goes for what appears to be Israel’s strategy toward both Gaza and the West Bank. Having created a huge, open-air prison in Gaza, Israel remains committed to a blockade that contains Hamas but also ensures that ever more Palestinians grow up angry. As for the West Bank, Prime Minister Binyamin Netanyahu has gone backward: He has said that Israel cannot relinquish security control of the West Bank for fear of Islamist attack. That implies an intention to consolidate the occupation, thus withdrawing all hope from Palestinian moderates. The West Bank would be likely to explode too, then, while the demographic clock ticked on.

For all the blood and misery in Gaza, Netanyahu soon will have a chance to show that he has heard the critics. Having won his battle, he should return to the negotiating table, this time with a genuine offer of peace. Every true friend of Israel should press him to do so.

From the Economist magazine.