In a small cell in Egypt's al-Marj prison, the BBC World Service brought encouraging news to Ayman Nofel. The senior Hamas commander from Gaza had just passed the third anniversary of his imprisonment on unspecified charges.

The voice coming from his radio told him that prisoners at another Egyptian jail had been freed amid the chaotic uprising sweeping the country. He saw his chance and wasted no time.

"I shouted to other prisoners to break down the doors and gates," said Nofel, who described himself as the only political prisoner among al-Marj's criminal population. Using smuggled mobile phones to mobilise locals to storm the prison gates, Nofel and his fellow-prisoners fought their way outside the walls and to freedom.

In an unintended consequence of the Egyptian people's revolt against decades of repression and economic misery, the Hamas militant accused of planning bomb attacks against Israel found himself at the centre of a hero's welcome in the Nuseirat refugee camp in central Gaza.

One by one, men queueing under the blue tarpaulin of a reception tent stepped forward to embrace the commander of the al-Qassam Brigades, Hamas's military wing. They flung arms around his shoulders, clapped his back vigorously and planted kisses on each cheek before turning to accept a celebratory sticky pastry and cup of potent Arabic coffee. Despite the festivities, Nofel, 37, a stocky man in a checked shirt, said he was ready to return to "work". Three years "and a few days" in the dank and wretched conditions of an Egyptian jail had not dulled his eagerness for what he described as "the next battle".

The Hamas commander claimed he was held for political reasons in Egypt after being detained at a security checkpoint in Sinai in 2008. "I never went on trial. My family got a lawyer, who went to court and got an order to release me but I was never freed."

His escape came amid the chaos of the early days of Egypt's revolution. Having broken out of the prison with help from local people he contacted "people here in Gaza". Hamas? "Yes, of course. They arranged for some Egyptians to pick me up," he said. Nofel stayed in a house in the area for about seven days "until the situation was more stable". Finally he was brought through a tunnel dug beneath the Egypt-Gaza border to his home and family. He was grateful to the Egyptian protesters who "inspired us to rise up against the prison guards. This should have happened earlier. They have spent 30 years being enslaved by the regime." He hoped to see the Muslim Brotherhood in power in Egypt – "and all over the world, not just Egypt".

Now, he would "resume my work with the Qassam Brigades. We are preparing and training for the next battle. This is our right."

Nofel's unambiguous support and gratitude for Egypt's revolutionaries has not been universally shared in Gaza. Fatah supporters are worried that President Hosni Mubarak's demise could boost the Islamist Muslim Brotherhood, the political partners of their arch-rivals Hamas.

"Hamas has not spoken a single word," said Gaza political analyst Mkhaimar Abusada. "My information is that they gave instructions to spokesmen not to say anything. They are closely watching the situation, but they don't want to publicly side with either the people or the government."

However, Hamas imams in Gaza's mosques had described the regime as a dictatorship and offered strong support to the attempt to overthrow the government, he added. "Deep in their hearts, Hamas is very happy because they believe the Mubarak regime was conspiring with Israel, the US and the [Fatah-dominated] Palestinian Authority to impose the siege on Gaza. But they are waiting to see how it plays out." Fatah supporters, he said, took the view that "my enemy's enemy is my friend. They know Hamas is keen to see Mubarak leave power. Any change in Egypt will not serve the interests of Fatah and the PA, but the interests of Hamas."

A senior Israeli government official said: "We have no doubt that Hamas is exploiting the current chaos in Egypt to advance its own interests, whether by arms smuggling or strengthening its terrorist infrastructure. We are deeply concerned about it."

On the streets of Gaza City, many people spoke of being glued to TV pictures from Egypt over the past fortnight. "I keep pushing my children out of the way," said Emtiaz Abu Watfa, 45. "If I could go there, I would. Mubarak will be forced out." Could she see similar scenes to those in Cairo's Tahrir square in Gaza City's Palestine square? "Inshallah. We want change everywhere, here in Gaza too. People are suffering. Democracy must take its place."

Basel Atwana, 32, a member of the leftist Popular Front for the Liberation of Palestine, agreed. "The Egyptian youth have become more aware of their rights, and they knew the road to Tahrir square. They will keep on fighting. One day we will do the same."

But minding his music shop, its shelves lined with CDs and DVDs featuring Egyptian stars, Fatah supporter Haytham Waheidy, 38, feared that Egypt could become another Iraq, racked by division and violence. "I think the Egyptian people deserve freedom, but Mubarak has promised change and they should give him a chance to implement this. It is outside interference that is keeping them in Tahrir Square."

The historical, cultural and social ties between Egypt and Gaza are strong. Gazans lived under Egyptian rule for almost 20 years until 1967; there are business and family connections; for three years Gazans almost exclusively consumed Egyptian products smuggled through the tunnels. "Egypt is everywhere in Gaza," said Abusada.