Mr Johnston said his time in captivity was the worst of his life
BBC correspondent Alan Johnston has been released by kidnappers in Gaza after nearly four months in captivity.
He said it was "fantastic" to be free after an "appalling experience". TV footage showed Mr Johnston, 45, leaving a building accompanied by armed men.
He later appeared beside Hamas leader Ismail Haniya and thanked everyone who had worked for his release.
Rallies worldwide had called for Mr Johnston's release. An online petition was signed by some 200,000 people.
The BBC reporter was handed over to officials of the Hamas administration in the early hours of Wednesday morning.
Gunmen from the Palestinian Islamist Hamas movement overran Gaza last month, expelling their rivals from the Fatah faction.
I literally dreamt many times of being free and always woke up back in that room
Alan Johnston
Mr Johnston was abducted on 12 March by the Army of Islam, a shadowy militant group dominated by Gaza's powerful Dugmush clan.
The group released three videos, two of which featured footage of the kidnapped correspondent.
It said it would kill its captive if its demands for the release of Muslim prisoners in British custody were not met.
'Dreamt of freedom'
Appearing at a press conference alongside Hamas leader in Gaza, Ismail Haniya, Mr Johnston thanked everyone who had worked towards his release.
"The last 16 weeks have been the very worst of my life," he said. "I was in the hands of people who were dangerous and unpredictable."
"I literally dreamt many times of being free and always woke up back in that room."
Mr Johnston said he was not tortured during captivity but he did fall ill from the food he was served.
He said Hamas' seizure of power in Gaza and its subsequent pledge to improve security in the territory had aided his release.
"The kidnappers seemed very comfortable and very secure in their operation until... a few weeks ago, when Hamas took charge of the security operation here," he said.
The journalist said he was moved twice during his spell in captivity.
Radio contact
Speaking earlier over the telephone from the house of Mr Haniya, Mr Johnston said: "It is the most fantastic thing to be free."
He described his experience of captivity as "appalling" and "occasionally quite terrifying".
"It became quite hard to imagine normal life again," he said.
He said he was looking forward to being re-united with his family in Scotland, expressing sorrow that his "actions" had brought turmoil to their lives.
He is said to have had a brief conversation with his father over the telephone after being released.
Mr Johnston said he stayed aware of efforts to free him by listening to the BBC World Service on the radio.
BBC's Gaza correspondent released
Mr Johnston said his time in captivity was the worst of his life
BBC correspondent Alan Johnston has been released by kidnappers in Gaza after nearly four months in captivity.
He said it was "fantastic" to be free after an "appalling experience". TV footage showed Mr Johnston, 45, leaving a building accompanied by armed men.
He later appeared beside Hamas leader Ismail Haniya and thanked everyone who had worked for his release.
Rallies worldwide had called for Mr Johnston's release. An online petition was signed by some 200,000 people.
The BBC reporter was handed over to officials of the Hamas administration in the early hours of Wednesday morning.
Gunmen from the Palestinian Islamist Hamas movement overran Gaza last month, expelling their rivals from the Fatah faction.
I literally dreamt many times of being free and always woke up back in that room
Alan Johnston
Mr Johnston was abducted on 12 March by the Army of Islam, a shadowy militant group dominated by Gaza's powerful Dugmush clan.
The group released three videos, two of which featured footage of the kidnapped correspondent.
It said it would kill its captive if its demands for the release of Muslim prisoners in British custody were not met.
'Dreamt of freedom'
Appearing at a press conference alongside Hamas leader in Gaza, Ismail Haniya, Mr Johnston thanked everyone who had worked towards his release.
"The last 16 weeks have been the very worst of my life," he said. "I was in the hands of people who were dangerous and unpredictable."
"I literally dreamt many times of being free and always woke up back in that room."
Mr Johnston said he was not tortured during captivity but he did fall ill from the food he was served.
He said Hamas' seizure of power in Gaza and its subsequent pledge to improve security in the territory had aided his release.
"The kidnappers seemed very comfortable and very secure in their operation until... a few weeks ago, when Hamas took charge of the security operation here," he said.
The journalist said he was moved twice during his spell in captivity.
Radio contact
Speaking earlier over the telephone from the house of Mr Haniya, Mr Johnston said: "It is the most fantastic thing to be free."
He described his experience of captivity as "appalling" and "occasionally quite terrifying".
"It became quite hard to imagine normal life again," he said.
He said he was looking forward to being re-united with his family in Scotland, expressing sorrow that his "actions" had brought turmoil to their lives.
He is said to have had a brief conversation with his father over the telephone after being released.
Mr Johnston said he stayed aware of efforts to free him by listening to the BBC World Service on the radio.