Alan Johnston, the BBC journalist held hostage in Gaza, was freed and handed over to Palestinian officials early on Wednesday after a late-night deal with the Al-Qaeda-inspired group that kidnapped him in March.
"It is just the most fantastic thing to be free," he told the BBC live by telephone from the home of Hamas leader Ismail Haniyeh. "(But it had been) at times quite terrifying."
"I dreamt many times of being free and always woke up back in that room. Now it really is over," said the 45-year-old Scotsman, adding he had followed events by radio and thanked the public and colleagues for their support throughout his ordeal.
Johnston, smiling and looking well despite four months in captivity, was embraced by BBC colleagues after he arrived by car at the home of Hamas's local leader in Gaza, Ismail Haniyeh.
He was ushered inside amid a scrum of well-wishers and security guards with Kalashnikov rifles.
Khaled Meshaal, the exiled leader of Hamas, said Johnston's release showed his Islamist movement was bringing order to the coastal enclave since seizing control last month after fighting with the Western-backed Fatah faction.
Palestinian officials said Johnston would hold a news conference with Haniyeh before being taken to British diplomats for a journey home through Israel.
Like most Western powers, Britain shuns Hamas for its refusal to abandon violence against the Jewish state and does not recognise Haniyeh's government in Gaza.
However, British diplomats have met Haniyeh in Gaza and discussed Johnston's plight in recent weeks. In London, no immediate comment was available from the British Foreign Office.
Meshaal told Reuters on phone, "We have been able to close this chapter which harmed the image of our people greatly. The efforts by Hamas have produced the freedom of Alan Johnston."
Referring to his rivals from the Fatah faction of Western-backed President Mahmoud Abbas, he said, "It showed the difference between the era in which a group used to encourage and commit security anarchy and chaos and the current situation in which Hamas is seeking to stabilise security."
The Palestinian ambassador to London, who represents the government Abbas set up last month after dismissing a Hamas-led administration, said Hamas wanted to "capitalise" on Johnston's release. But he said, "The credit goes to the Palestinian people. We believe in freedom of the press."
Johnston, the only Western correspondent working full-time in the troubled coastal enclave, went missing on March 12 when his car was found abandoned.
His captors later declared themselves to be the Army of Islam, a group with Al-Qaeda-inspired rhetoric and links to one of Gaza's powerful clans.
They issued Web videos showing Johnston and seeking the release of Islamists held prisoner by Britain and other states.
Most recently, after Hamas officials threatened to free him by force from the clan's stronghold, Johnston was shown wearing a suicide belt with the warning he would die if that happened.
Hamas, apparently eager to show its ability to impose order in Gaza after many months of factional fighting, had increased pressure on the hostage-takers to relent and had surrounded their neighbourhood late on Tuesday.
The Army of Islam and Hamas exchanged prisoners in recent days during negotiations to free Johnston.
Hamas was elected to run the Palestinian government 18 months ago but was shunned by Israel and Western powers.
Its local leader, Haniyeh, still considers himself prime minister but Abbas has appointed an emergency government without Hamas involvement in the larger territory of the West Bank.