There may be more Hamas militants in the north of Gaza, supposedly cleared by Israeli forces months ago, than in Rafah, the southern city in the territory described by Israeli officials as the extremist Islamist organisation’s “last stronghold”, analysts believe.

More than 1 million people have fled Rafah, Gaza’s southernmost city, after instructions from the Israel Defense Forces (IDF), the biggest wave of displacement since the early months of the conflict. The IDF has said repeatedly that four Hamas brigades – the militant Islamist organisation’s biggest remaining force – is based in Rafah.

But though Israeli forces have now invaded Rafah, it was fighting in Jabaliya, the second-most populous town in northern Gaza, that was described last month by IDF officials as “perhaps the fiercest” yet seen in the seventh-month-long conflict.

“We do have to remember there are more Hamas armed people in the north of Gaza in the places that the IDF has already moved out of than … in Rafah … Those are the IDF’s numbers. This is why the IDF had to go back into Jabaliya and … Zeitoun [a nearby town]. Hamas is controlling all those areas,” Eyal Hulata, the head of Israel’s national security council from 2021 to last year, told reporters last month.

Israeli officials, including the prime minister, Benjamin Netanyahu, have long claimed that the ongoing offensive in Rafah, despite strong opposition from many allies, will achieve their stated war aims of destroying Hamas’s capability to threaten Israel and freeing hostages held by the group.

The battles in Jabaliya between lightly armed Hamas militants and a powerful IDF force underlined the ability of Hamas to return to parts of Gaza from which it was forced to retreat by earlier Israeli offensives, threatening a “forever war” for months or even years to come, as Israel tries to stamp out a tenacious insurgency, experts say.

“Hamas was in complete control here in Jabaliya until we arrived a few days ago,” the IDF said before its May operation, four months after its spokesperson Daniel Hagari claimed that militants were operating in the area only sporadically and “without commanders”. Last week, Israel said its offensive in Jabaliya was complete, but it is not clear whether the militants were defeated or had simply moved elsewhere.

The resurgence of Hamas is not limited to sending armed men back to areas such as Jabaliya but also involves a concerted effort to maintain the group’s authority over all aspects of civilian life.

“This is not some kind of shadow government. There is only one dominant, prominent authority in Gaza and that is Hamas. The leaders of Hamas are very flexible and they have adapted to the new situation,” said Michael Milstein, from the Moshe Dayan Center for Middle Eastern and African Studies, an Israeli thinktank.

Hamas seized power in Gaza in 2007 and ruled inside the territory until the Israeli offensive last year, which followed surprise attacks into southern Israel in October that killed about 1,200 people, mostly civilians, and in which 250 were taken hostage.

Residents of Jabaliya said they had seen Hamas officials last month patrolling markets, enforcing price controls on key goods and organising distribution of aid.

Israeli troops near Gaza. The difficulties faced by the IDF in achieving a decisive victory may discourage Hamas from agreeing to a peace deal Photograph: Menahem Kahana/AFP/Getty Images

“There was a Hamas government in control, especially through the police, but it was low profile because they were being targeted and they did just very basic duties. It wasn’t like before the war,” said Joe Shamala, 26, a resident who had fled the town recently.

Other civil organisations more or less run by Hamas also allow low-profile but effective governance.

The difficulties faced by the IDF in achieving a decisive victory may discourage Hamas from agreeing to a new peace deal presented by Joe Biden on Friday.

Sources close to Hamas say Yahya Sinwar, its leader in Gaza, believes that the humanitarian crisis in the territory and growing international outrage towards Israel strengthens Hamas in negotiations.

Prosecutors at the international criminal court want to arrest Netanyahu and Yoav Gallant, the Israeli defence minister, on charges of war crimes and crimes against humanity, but also Sinwar, his deputy, Mohammed Deif, and Ismail Haniyeh, the political leader of Hamas living abroad, on similar charges.

Hamas has denounced the move, though it is unlikely to influence its decision-making in any significant way.

“Sinwar and Deif absolutely believe they will die in the war or the Israelis will kill them afterwards and they don’t have any respect for something like the ICC anyway. [Charges] might be a minor inconvenience for Haniyeh but there are plenty of places he can go where he’d be safe from arrest or whatever,” said one source who speaks regularly with Hamas’s leadership.

More than 36,000 people have died in Gaza since the beginning of the Israeli offensive, mostly women and children, according to local health authorities. The figures do not differentiate between combatants and civilians.

Many analysts caution that Hamas can easily recruit new members to rebuild its strength and that fighting a war of attrition against a “guerrilla army” with some popular support among a population of more than 2 million is impossible.

“My cautious assessment is that Hamas still has a lot of weapons … You can take a 16- or 17-year-old and give him a rifle or a rocket-propelled grenade and there is a new fighter,” said Milshtein.

Mkhaimar Abusada, professor of political science at al-Azhar University in Gaza, believes the high civilian casualties will spur recruitment.

“There is a widespread belief that Israel is not at war with Hamas, but with the Palestinian people,” he said. “Hamas won’t claim victory, not after all this death and destruction, but will not surrender. That is just not in their vocabulary.”

Netanyahu has resisted pressure from allies and the IDF to outline a plan for civilian administration of Gaza for fear of losing the support of far-right ministers who have explicitly advocated the reoccupation of Gaza by Israel and the “voluntary migration” of its residents.

A series of US officials have warned Israel recently that allowing a security vacuum to develop in parts of Gaza is a major strategic blunder.

The US secretary of state, Antony Blinken, said Israel was “on the trajectory, potentially, to inherit an insurgency with many armed Hamas left or, if [Israel] leaves [Gaza], a vacuum filled by chaos, filled by anarchy and probably refilled by Hamas.”

Max Boot, a columnist at the Washington Post and author of a history of guerrilla warfare, wrote that he had been told by one US official: “The Israelis are showing how not to do counterinsurgency.”