FOR most of his tenure, Israel's prime minister, Binyamin Netanyahu, seemed uncannily alert to the lesson taught by his predecessor against waging unnecessary wars. Ehud Olmert’s offensives in Lebanon and Gaza saw his popularity plummet from 85% in the first of days of 2006 Lebanon campaign to 3% in the months that followed, amid recriminations and a commission of enquiry into his war-time decision-making. The offensives not only cost him his re-election prospects but led to the loss of Israel’s strategic alliance with Turkey, and worsened its standing worldwide. Careful to avoid those pitfalls, Mr Netanyahu opted for prudence, talking tough but acting with often marked restraint. If the Palestinians were quiet for much of his tenure, it was largely because Israel was. But Mr Netanyahu’s decision to kill Hamas’s military chief, Ahmad Jabari—apparently by luring him into a trap—has put all that at stake. Fearful that challengers in the run-up to Israeli elections would dismiss his sabre-rattling as mere show, his war on Gaza appears designed to shore up domestic support. Of particular concern for Mr Netanyahu are the towns bordering Gaza, which are traditionally a stronghold of his Likud party. But its population is angered and exhausted by sirens that give them only seconds to rush for shelter, and called on Mr Netanyahu to act. The longer the fighting continues, the harder the outcome becomes to predict. Six days of fighting has already shaken Israel’s main population centres in Jerusalem and Tel Aviv. Many of its people hitherto felt untouched by Gaza’s war and siege, but may yet blame Mr Netanyahu's killing of Mr Jabari for spoiling the calm. With continued rocket attacks south of Jerusalem, Mr Netanyahu faces public pressure to launch a ground offensive. But the fallout is unlikely to be only domestic. The assault on Gaza risks triggering unrest in the West Bank, Palestine’s other half which has been largely peaceful for six years under the rule of President Mahmoud Abbas and the Palestinian Authority (PA). Buoyed by a sense of empowerment from their strikes on Tel Aviv, despite the limited damage, Palestinians have rallied to Hamas there as well as in Gaza. “No one from the left or right can criticise Hamas in the West Bank now,” says a left-wing political activist in East Jerusalem. “They have proved that they can defend Palestinians, and develop a strong country, while the PA fritters its time on an international arena which gives it nothing.” Inspired by the fighting in Gaza, skirmishes between Palestinian youths and Israel’s forces in the West Bank have increased markedly in recent days.

Regionally, too, further Israeli escalation could put relations with Egypt on a knife-edge. Having forfeited one regional ally, Turkey, in its 2008-2009 Gaza offensive, Israel is loath to lose another in this one. Yet given the region's new geo-political map, increasingly its assault on Gaza is viewed not only as a war on Hamas but on the Sunni Islamist ascendency, as in Syria. Under pressure from Western allies to preserve his relations with Israel, Muhammad Morsi, Egypt's president, is running out of options to assuage Muslim Brotherhood anger at the bombardment of its Palestinian offshoot, Hamas. He has already withdrawn Egypt’s ambassador from Israel, and is facing strident demands to sever relations altogether.

Sinai’s instability compounds the uncertainty. Militant groups there have used the peninsula as a launchpad for rocket-attacks on Israel. Should Israel deem Egypt unable to control Sinai’s militants and resort to military action on Egyptian soil, it could well find itself embroiled in open confrontation with Mr Morsi’s new regime. Nor can Mr Netanyahu rely on unmitigated Western support. Fearful that escalation could further unsettle its fragile ties with Egypt and heighten unrest elsewhere in the region, including Jordan, America's president, Barack Obama, has already warned Israel against a ground offensive.

Hence Israel’s interest in an early ceasefire. Its generals have offered to hold fire if Hamas does, and Mr Netanyahu has sent as his chief negotiator, Yitzhak Molcho, to Cairo to negotiate terms. But Hamas is pressing for a more formal arrangement, including guarantees that Israel will halt assassinations and normalise trade relations. It wants Israel to lift its land and sea blockade, and restore access to what were hitherto its primary markets in the West Bank and Israel. It also wants Egypt to re-open the border crossing at Rafah to goods traffic.

Hamas leaders argue that Israel’s offensive has played into its hands by winning the movement greater regional recognition. Egypt’s prime minister, Hisham Kandil, has visited the enclave, as has the Tunisian foreign minister, Rafik Abdesslem. An Arab League delegation and Turkey’s foreign minister, Ahmet Davutoglu, arrived on November 20th. The head of Hamas’s politburo, Khaled Meshal, has held talks in Cairo with the Egyptian and Turkish officials. (With his rivals inside Hamas hiding in Gaza for fear of Israeli attack, Mr Meshal is back in the limelight, his prospects for continued leadership of the movement enhanced.) French and Italian officials have also offered their services, apparently as monitors of a future ceasefire.

Should the dust settle sooner rather than later, both sides could emerge with their political standing enhanced. Hamas will be seen to have bolstered its position inside the Palestinian camp, particularly in the West Bank, where protesters are again flying the Hamas flag. Mr Netanyahu could claim that he significantly weakened Hamas’s missile capability, at least for now, and face down critics who claimed his military threats were just bluffing.

While the initial ceasefire may only amount to a cessation of hostilities, the challenge for both Israel and Hamas, once the Israeli election on January 22nd is over, will be to translate it into something longer lasting. Both have more to gain than just quiet. With Hamas now detached from Lebanon's Hizbullah, Syria and Iran and firmly in the Sunni camp of American allies, including Turkey, Qatar and Egypt, the attraction for Israel and Western powers to opt for political over military engagement has increased. For Israel, a transformed relationship with Gaza could yet offer a conduit for an improved relationship with the region’s new Islamist powers. For Hamas, engagement with Israel could provide a means to transform its relationship with Western powers.