ABSORBED by speculation about their government's future after an inquiry commission this week released its final report on the 2006 Lebanon war (see article), Israelis seemed briefly to forget about last week's dramatic breach of the Gaza-Egypt border by Hamas, the Islamist movement that controls the Gaza Strip. Yet in Gaza as in Lebanon, the short-sighted planning that the Winograd commission criticised was much in evidence. More to the point, there is a gloomy sense among Israelis, alongside a pleasurable mood of Schadenfreude across much of the Arab world, that Israel has taken a bad knock.

The border breach seems to have taken Israeli leaders and generals by surprise, yet there was no shortage of warnings. Blowtorched perforations outlining a large hole in the corrugated-iron border fence had been noticed by outsiders in October and mentioned in meetings with Israeli officials. A European military source says Egyptian officers first warned their Israeli counterparts in November of a possible breakout.

Perhaps a stream of such low-level alerts had dulled the military planners' senses. And Hamas bided its time. After an Israeli suspension of fuel deliveries provoked widespread power cuts, Hamas took advantage of international sympathy to knock down the border wall, letting hundreds of thousands of Palestinians stream into the nearby Egyptian towns of Rafah and el-Arish to stock up on goods.

The mood among Gazans was one of euphoria mixed with desperation, as young boys, old women and hardened traders and smugglers scrambled up and down ladders and struggled across ditches under the flattened wall to grab whatever they could from Egyptian shops and hawkers on the other side. The array of goods, some on donkey-carts, others on pick-up trucks, mostly on people's backs, was baffling in its magnitude: bags of cement, mattresses, Japanese scooters, goats, cows, chickens, flour, washing-up liquid and soap, cans of every sort of fuel, chairs; in one battered car, four live sheep were crammed into the back seat. But the sense of freedom and exhilaration was also mixed with foreboding. No one seemed to know what the future might hold.

By this week Hamas militants were co-operating with Egyptian troops to put the barbed wire back up. But this is the third time Hamas has taken the world by surprise by keeping its extensive preparations discreet enough to be just under the radar. And as with the first two times—its overwhelming election victory two years ago and its rout of forces loyal to Fatah, its secular rival, in Gaza last June—most would agree it has shifted the strategic balance.

The Egyptian and Israeli strategy, discreetly backed by many Arab countries, of strangling supplies to Gaza as a way to squeeze the population and make Hamas unpopular has backfired. Hamas, which rejects a peace deal with Israel, is now seen as the people's saviour, while Fatah's Mahmoud Abbas, the moderate Palestinian president with whom Israel is holding peace talks in the hope of making him a more attractive choice to Palestinians, looks weaker than ever. The breach also made Israel's border with Egypt, which is 255km (158 miles) long and in many places has no fence, vulnerable to infiltrators. Police in Sinai reportedly apprehended at least one team of armed Palestinians, equipped with suicide belts, sniper rifles, and detailed plans of Israeli border installations.

Above all, pressure has shifted onto Egypt. Many Israelis would be happy to dump Gaza and its troubles in Egypt's lap. But as an offshoot of Egypt's Muslim Brotherhood, the main opponent to the regime of the ageing Hosni Mubarak, Hamas has considerable leverage over Egypt. The Brotherhood had sponsored dozens of demonstrations in the week before the breach, demanding relief for Gaza. Hamas has also been skilled at manipulating wider Arab opinion through television channels such as al-Jazeera, where its leaders swiftly moved from slamming Mr Mubarak for collaborating in the siege of Gaza to praising him after he let the Gazans in. With viewers riveted to scenes of the Gazans' joy at even a brief escape, the Arab mood was captured by Muhammad Abu Trika, a star Egyptian footballer, when he received a warning for raising his jersey after scoring during the current Africa Cup to reveal a T-shirt emblazoned with “Sympathise with Gaza”.

Hamas's action succeeded also in sowing discord among its foes. Israel has long accused Egypt of failing to stop smuggling across the border, to the point that its supporters in Congress had conditioned part of America's $1.7 billion in annual aid to Egypt on imposing tighter controls. The breakdown of control led to still more bitter recriminations. Right-wing Israeli commentators claim the Egyptians may themselves have engineered the border collapse, with the aim of incorporating Gaza as part of a long-term strategy to encroach on Israel. Egyptian conspiracy theorists see, instead, an Israeli plot to dump Gaza and its troubles on them. Egypt's tight-lipped foreign ministry blamed Israel for the problem, saying it remained Israel's responsibility, as an occupying power (though it withdrew its troops and settlers in 2005), to find a solution to Gaza's woes.

Yet Hamas cannot afford Gaza to lose all its economic ties with Israel or its political ties with the West Bank; it cannot even issue passports that anyone will recognise. So there is scope for compromise, but, says Ezzedine Choukri-Fishere, a former Egyptian diplomat who runs the Cairo office of the International Crisis Group, a Brussels-based lobby, “unless somebody comes to their senses it will be difficult to achieve results; there are four parties involved, all tied to each other, like four boats. None can move alone, or impose a solution without engaging the others.” Hamas has proved that Gaza's isolation cannot go on and that it can obstruct. “But it is now drunk with its victory, and thinks it can force Egypt into an agreement that would exclude the PAand Israel.”

No wonder, then, that Egypt ordered its troops to let Gazans in for a few days and summoned a Hamas team, led by Mahmoud Zahhar (see article), to Cairo for talks with Fatah to hash out a new deal for securing the border. Mr Abbas wants the interim government he appointed after Hamas's Gaza takeover in June to resume control of the Gaza-Israel crossings, perhaps with European supervision at the Rafah one into Egypt, as per a deal reached in 2005. The Arab League, the Europeans and the Americans back him.

However, none of them wants to involve Hamas in the arrangement. Hamas, for its part, wants more say in running the crossings, particularly the Rafah one. As it has shown, it can spoil any scheme it doesn't like; in any case, nobody else can run the crossings without its acquiescence. It has used the crisis to repeat its demand for unconditional dialogue with Fatah, while Mr Abbas insists that it first apologise for the bloody overthrow in June. Meanwhile, Israel has so far rejected any new border deal.

Don't say Hamas is winning

Some prominent Israelis dismiss the idea that its squeeze-Gaza strategy has failed. “So Hamas destroyed the fence—so what?” says Ephraim Sneh, a former general and minister who is a member of parliament for the Labour party, which is part of Israel's ruling coalition. “It can't restore the economy without connections with Israel. If they keep firing rockets we'll just close the border again.”

Many others disagree. Hawks think that since economic pressure and the continuing assassination of Hamas fighters have not stopped the Palestinians firing rockets from Gaza or weakened Hamas, a full military takeover of Gaza is the only remaining option. But that would be bloody. Hamas has been following the example of Hizbullah, Israel's foe in south Lebanon, preparing bunkers and tunnels, reinforcing buildings and laying anti-tank mines along likely approach routes. Eliminating Hamas's militia would take months, and the army might have to stay in place for years—unpalatable echoes, especially in the wake of the Winograd report, of both the 2006 war in Lebanon and Israel's earlier 18-year occupation of it.

More pragmatic Israelis such as Ami Ayalon, a former head of Israel's domestic security agency, the Shin Bet, who is a minister in the coalition government, argue for a ceasefire with Hamas in Gaza. The Islamists themselves have given hints that they are open to this, having previously demanded that it extend to the West Bank too. The daily dose of rockets has dropped sharply since last week, suggesting that Hamas does have some control over the other groups that fire them and possibly signalling its openness to a deal.

Until something moves it will be ordinary Gazans and the rocket-weary residents of Israel's southern towns, especially Sderot, who pay the price. According to the UN, Gaza's power supplies are still running at 75% of normal, which means long power cuts in most places, sporadic running water, and 30m litres of sewage a day being dumped near the beaches that are one of Gaza's few natural resources. Even the most basic food aid (including flour and sugar) is not getting in fast enough, and rubbish is piling up in the streets.

A lasting solution may not come quickly. Each party, including Hamas, can make political capital from the continued closure of the borders, as long as it is not the one getting blamed. But Hamas is the one that has gained in strength, while the others, Egyptian and Israeli governments included, are on the defensive.