By Jeremy Bowen
BBC Middle East Editor
Now that Alan Johnston is free, Hamas hopes it has delivered several messages - the first is to any potential rivals in Gaza about who is boss.
The second, and most important of all for Palestinians, is that it is dedicated to ending the appalling lawlessness of the last few years.
Alan's release might encourage a Hamas and Fatah rapprochement
The third message, aimed at the outside world, is that the release of Alan Johnston shows that Hamas is responsible, and powerful.
It hopes to make itself impossible to ignore - and vital to engage.
To get the mood in Gaza, I rang the BBC's excellent Fayed Abu Shamala, our senior journalist there. No-one worked harder to get Alan Johnston out.
He gave a vivid account of the last few days in Gaza, which I think is worth quoting at length.
"Today Gaza really feels different. It was so tense before Alan was released that I thought the rocks were dancing.
"Now, you could feel the relief of all the Palestinians. It's as if we're at a crossroads - 99.9% of Palestinians felt shame about what happened to Alan, so today we're happy.
"We hope no-one is going to dare to try any more kidnaps, because they know what they'd face.
"It's not like those simple days when they could kidnap someone and settle it by getting a salary or some bullets from the Palestinian Authority."
He talked about the night before Alan Johnston was released from his captors, a group calling itself the Army of Islam sponsored by the Dugmush family, one of Gaza's armed clans.
"The evening before Alan was freed, everyone thought it would be a bloody night in the area the Dugmush control.
"Hundreds of Hamas fighters were moving closer, through the alleys around there. The Dugmush family could feel the pressure.
"The Hamas people were very serious, very tough. They told the family that the kidnap was going to end whatever happened, and that this was their last chance to finish it by talking.
"The Hamas condition was always: 'You release Alan, and we'll talk about anything.' Even after they did the deal, the time before they could get Alan out - a couple of hours - was very tense, very critical and heavy. Every moment was a lifetime.
"There was a constant fear of violence - what if someone had started shooting, or fired a rocket propelled grenade? People would have been killed. Alan might have been killed," he said.
Alan Johnston was released because the Dugmush family realised it had no other choice.
When I visited Khaled Meshal, the leader of the political wing of Hamas, in Damascus last week, he told me that their strategy was to build pressure on the kidnappers until they cracked.
To make reality a little more palatable, a deal was done about an exchange of prisoners, and a fatwa was issued by a cleric authorising Alan's release.
The BBC's Fayed Abu Shamala and others in Gaza recognise that things are not going to be easy.
Hamas wants to impose law and order but there are plenty of issues they need to sort out before that can happen.
For example, blood has been spilt in shoot-outs between the Dugmush and other powerful families, and issues of revenge need to be settled.
But if Hamas can bring law and order to Gaza, then it will increase its legitimacy. The biggest complication is that Gaza is not an island in a benign sea.
Hamas says it wants a rapprochement with Fatah, the other big Palestinian faction.
But so far, Fatah - still stinging from the defeat inflicted by Hamas three weeks ago - says it has no interest in dealing with a group that perpetrated what it calls a "military coup".
And there is Israel, which controls Gaza's borders, its airspace and its sea coast.
At least six Hamas members were killed in an Israeli raid into Gaza the night after Alan Johnston was released.
Most Israelis regard Hamas as a terror organisation that would destroy their state if it could.
Speaking to the BBC on Thursday, the Israeli foreign ministry spokesman Mark Regev rejected the idea that Hamas was moving along a political track, had implicitly recognised the existence of Israel and would accept a Palestinian state standing alongside it.
He said that while he accepted the existence of Aids, he would still like to destroy it. In other words, Israel believes that Hamas - whatever it says for foreign consumption, is still out to kill Jews.
Israel may not like it, but there are signs that some people in influential positions in the West are changing their view of Hamas after everything it did to release Alan Johnston.
For the new British foreign secretary, David Miliband, it amounted to a change of tone. He welcomed the part played by Hamas, and mentioned its prime minister, Ismail Haniya, by name.
Others go much further, believing that the policy of isolating Hamas because it will not recognise Israel or renounce violence, is looking threadbare, not least because it seems to play into the hands of the extremists.
A group of British parliamentarians has signed a motion in the House of Commons calling for engagement with Hamas.
The mood was summed up in the final despatch sent back to the UN by its Middle East envoy, Alvaro De Soto, before he retired earlier this summer.
He wrote that Hamas "can potentially evolve in a pragmatic direction that would allow for a two-state solution - but only if handled right".
Long after Alan Johnston gets back to his family in Scotland, the Middle East will still have intractable problems.
His release brought joy to his family and friends, and all the people around the world who supported him while he was a prisoner, but it will not create any political miracles.
But it might provide an opening, and there are not many of those in the Middle East at the moment.