By Alan Johnston
BBC News, Gaza
For now at least, the Palestinian quest for political unity is on course.
Ismail Haniya (left) and Mahmoud Abbas sealed the deal in Mecca
There were fears that the agreement struck last week in Mecca to form a new national unity government might be unravelling.
Serious differences had suddenly emerged regarding security issues and appointments to key cabinet jobs.
And so there was an air of relief and celebration when the leaders of the Hamas and Fatah factions emerged from talks in Gaza City to announce a major step forward.
The old Hamas-run administration had resigned, and its Prime Minister Ismail Haniya had been asked to establish a coalition government along with his rivals in Fatah.
"The mood is really good," analyst Mukhaimer Abu Sadr said of the feeling in Gaza. "Yes we do still think there are some obstacles here and there, but overall there is lot of relief."
The vast majority of Palestinians are desperate for the government to come together smoothly and succeed.
They want to see their leaders form a united front in their confrontation with Israel and the effort to end its occupation of their land.
And even more pressingly, they have been appalled and frightened by the violence in recent months between forces loyal to Hamas and Fatah.
Dozens of people were killed in Gaza in bout after bout of increasingly fierce clashes that seemed to be edging this society towards civil war.
And the bloodshed in the streets has left some sceptical and wary. Among them is a hospital nurse, Riyadh Al-Adassi, who spent many days treating those injured in the fighting.
"I lost my faith in both factions," he said of his reaction to the moves to set up the new government.
"It's hard for me to be happy since the price was so many murders - and so many casualties. We shouldn't have to pay such a price for those so-called leaders to manage their problems.
"I had the first bit of relief when I watched the news that Haniya had resigned. But there's a big difference between planning a thing and implementing it," Mr Al-Adassi said.
But for now at least the coalition deal has halted the killing.
Scores have been killed in factional fighting
As soon as the Mecca Accord was announced the factional tensions started to ebb away, and Gaza is at the moment enjoying a rare period of calm.
Of course though, there is no guarantee that this will last.
The rivalry between Hamas and Fatah is intense. There are real ideological divisions and bitter personal animosities.
This is a political marriage made in hell. The relationship is bound to be fraught, and there must be a danger that the government will experience more paralysis than progress.
"There will be so many problems day by day," said Mr Al-Adassi. "So how will they fix things? Will it be guns or endless talks? These are the kinds of questions people like me want answers for."
Even assembling the administration might be hard going. The differences over security issues and key appointments are still all unresolved.
But both factions know that the alternative to working together may well be more street fighting - and they are both aware too that they cannot deliver a knock-out blow.
At the same time, the coalition deal was brokered by Saudi Arabia, which can be expected to have an enduring interest in its success.
Palestinians will be hoping queues for food handouts will become a thing of the past
If there was to be some major crisis in the weeks or months ahead, Hamas and Fatah might well be invited back to Mecca to resolve their problems in the forceful presence of their Saudi mediators.
And so despite what may be many difficulties to come, this is a time for some very cautious optimism that there will be a lasting improvement in the security situation.
But the unity government is not only being formed in an attempt to stop the bloodshed. It is also a bid to put an end to Israeli and Western economic sanctions - and this may well prove an even bigger challenge.
The outgoing Hamas administration was boycotted because it refused to renounce violence and recognise the state of Israel's right to exist.
The new coalition has a more moderate stance. Going into the coalition Hamas agreed to "respect" past Palestinian peace deals. This would seem to imply recognition of Israel.
But all the signs from Washington are that the US is unimpressed. It can be expected to demand an explicit statement of recognition.
The Americans and at least some of the European Union states would say that that is a precondition for any hope of progress towards a peace settlement that envisages a Palestinian state emerging alongside Israel.
And so a rapid lifting of the Western embargo is most unlikely. And President Mahmoud Abbas conceded that in a television interview.
He told his people that the boycott would not be lifted right away, but "we will fight and struggle, and we hope that this can be accomplished soon".
And some in the international community may well conclude that Hamas's commitment to "respect" past agreements was enough, and that it is time to re-engage.
It is possible that there will eventually be a split in Western ranks, with some states re-establishing connections with the government, and others continuing to boycott it.
Palestinians will hope that there will be new Arab efforts to breach the financial embargo. There have been reports of the Saudis being prepared to make a billion dollars available to the new government.
But unless there is a reliable flow of funds from abroad it will be very difficult for the coalition administration to tackle the vast social and economic problems that beset the Occupied Territories - and which give rise to so much political tension of all kinds.