By Alan Johnston
BBC News, Gaza
The Gaza Strip has endured days of tension - witnessing some of the worst violence between Palestinians for years.
The ceasefire followed days of clashes between Hamas and Fatah
The powerful militant movement Hamas has clashed repeatedly with the government's security forces.
There have been efforts bring the crisis to a halt. But it may be days before we know if they have been successful because sporadic clashes have continued.
The violence, however, has shown again what a serious challenge Hamas poses to the Palestinian Authority (PA).
Again and again Israel has demanded that the Palestinian leadership move to break Hamas - to disarm it and jail its leaders.
But events on the streets of Gaza have made it clear how very unlikely that is to happen. In almost every encounter, the security forces came off worst.
In the northern town of Beit Lahiya and the Zietoun area of Gaza City, the Palestinian Authority stepped back from the fight.
In both places the security forces' vehicles were burnt and their outposts set ablaze.
And Hamas sent a chilling message that individuals within the PA might pay - personally - for confronting the militants.
The day after the first clash a senior security force officer involved was shot and injured. And after Hamas men were fired on early on Wednesday the movement targeted the homes of top security force figures.
Independent analyst Bassam Nasser says Hamas has made its rules clear.
"Hamas is saying you don't dare stop our men because we will catch you - as an individual officer, as an individual policeman. Whatever your position, Hamas will respond with heavy ammunition."
'Right to respond'
The violence broke out when the Authority's security forces intercepted a Hamas team on a mission to launch rockets at Israeli targets.
Hamas influence has grown during the intifada
Hamas says it has the right to respond to what it regards as Israeli acts of aggression on occupied Palestinian land.
The Palestinian leader, Mahmoud Abbas, on the other hand, is committed to a ceasefire with Israel.
The move against Hamas then, was an attempt by Mr Abbas' administration to impose its authority - to try to show the militants that there were limits.
And although the government's forces came off second best, the tensions were so acute that Hamas did start reining itself in.
As Egyptian mediators worked to calm the situation, the Hamas rocket attacks on the Israelis tailed off - and the ragged ceasefire was restored.
In that way, Mr Abbas and the Authority achieved their goal - for the moment at least.
Hamas vs. Fatah
But this was not just a dispute between Hamas and the PA.
Just below the surface it was a confrontation between the militants and the Fatah faction.
The late Yasser Arafat's old party, Fatah dominates the PA and its security agencies.
When the two sides wanted to talk peace late on Tuesday, it was Fatah leaders who sat down with Hamas.
The two sides agreed to step back. They took their armed men off the streets of the north first, and then tried to spread the calm to the rest of the Strip.
The tension between Fatah and Hamas has been building for a long time.
Fatah is in trouble. The PA that it runs is widely seen as having failed the people on many fronts.
Both the PA and the party are regarded as badly run, and tainted by corruption. Fatah's support has been ebbing.
Hamas though, is on the rise.
Israel may regard the group's suicide bombers as the worst of its terrorist enemies.
But here in Gaza, Hamas is admired as a resistance movement. It is seen as taking the fight to the Israeli forces that have occupied the Strip for decades.
And perhaps more importantly, Hamas has built a reputation for honesty and good management of its health, food aid and other programmes for poor families.
Hamas has won important victories in local elections. And it stands to become a real force in parliament if and when general elections are held.
In the local elections months ago, Hamas demonstrated its power at the ballot box.
And over the past few days - in the violence on the streets of Gaza City - Hamas showed that it is a match for the armed forces that Fatah has at its disposal.