Other shows of force included armed men wielding assault rifles marching through a market in the Zeitoun area followed by a small group waving a Palestinian flag.

“I think what Hamas has been trying to do is mobilise its forces, using its interior ministry forces, to assert and consolidate its control,” Professor Fawaz Gerges, Professor of International Relations at the London School of Economics, told the BBC’s Today Programme.

“In the areas where it’s Hamas control, Hamas will be able to destroy the various clans and gangs and looters and militias because its forces are more seasoned, more skilled, more determined,” he added.

While Hamas has long had simmering rivalries with various armed groups in the Strip, Israel’s bombardment of Gaza and the loosening of Hamas’s grip on power has allowed some of the clans to grow in strength, analysts say.

“The collapse of other social institutions has increased the appeal of the clan, which can serve as a social network for its members,” Yaniv Voller, a senior lecturer in Middle East Politics at the University of Kent, told BBC Verify.

“At least some of the clans have been reported to have received weapons and other support from the Israel Defense Forces (IDF), to serve as proxies against Hamas,” he added.

Some of the militias are also operating in IDF-controlled areas. By analysing videos circulating on social media, BBC Verify identified bases used by two rival groups deep inside IDF controlled territory, including one near the southern city of Rafah, and one ​​near the northern town of Beit Hanoun.

In response to Hamas’s re-emergence and the role of its security forces in policing, Trump previously said this did not fall outside the peace agreement.

“[Hamas] do want to stop the problems and they’ve been open about it, and we gave them approval for a period of time,” he told reporters on Monday.

“You have close to 2 million people going back to buildings that have been demolished, and a lot of bad things can happen. So we want it to be – we want it to be safe.”

Prof Gerges said that the US and its allies had little choice but to allow Hamas to exhibit some show of force in Gaza if the ceasefire was to have any meaningful impact.

“Without security you cannot deliver aid. Without security you cannot really have life,” he said. “The Americans realise that the only force is Hamas and that’s the irony.”

Additional reporting by Emma Pengelly and Ahmed Nour.