Updated

The first night after he was snatched in Gaza nearly four months ago, BBC reporter Alan Johnston feared he was about to die.

The kidnappers' masked leader appeared in the doorway, and moments later the prisoner was handcuffed, hooded and taken outside.

But the Palestinian gunmen were just moving him to another hideout, and Johnston settled into a grim captivity, much of which he spent in a dark room, often watched over by a guard who rarely spoke but was prone to flying into rages.

• Click here for FOXNews.com's Middle East center.

Until his release before dawn early Wednesday in a murky deal between his kidnappers and Gaza's Hamas rulers, Johnston said he had only one link to the world — a radio that picked up British Broadcasting Corp. reports on the frantic efforts to free its correspondent.

Johnston, who emerged gaunt but smiling, told the BBC he was often unsure if he "was going to live or die," and expressed thanks for all those who worked for his release.

"I'm so immensely grateful for that, and I will be all my life," Johnston said in Jerusalem, addressing a BBC rally in London celebrating his release.

Johnston, a native of Scotland who reported from Gaza for the BBC for three years, was grabbed on a Gaza City street by masked gunmen March 12, shoved into a car and spirited away.

He was the latest in a string of foreigners kidnapped in Gaza, and his time in captivity was by far the longest. Even before it happened, he said, he had often envisioned being kidnapped.

"It was a vaguely surreal experience, as if I'd lived it before, because I'd imagined it so many times. And there I was, before I knew it, on my back in the back seat with a hood over my head," Johnston said at a news conference at Britain's consulate in Jerusalem, where reporters greeted him with applause.

That first night, Johnston said, he feared he was about to die.

At 2 a.m., the gunmen's leader appeared in the doorway, his face concealed by a red-and-white checkered headscarf, and told the journalist he wouldn't be hurt, the reporter recalled.

He wasn't sure whether to believe that.

Not long afterward, Johnston said, "They woke me up, and put a hood over my head again, and handcuffed me, and took me out into the night, and of course you really wonder how that might end."

But they only moved him to another hideout.

Johnston was held by the Army of Islam — a group inspired by Al Qaeda and run by one of Gaza's most notorious and heavily armed crime families, the Doghmush clan.

"The last 16 weeks, of course, were just the very worst you can imagine of my life, like being buried alive, really, removed from the world," Johnston said.

During his captivity, the world saw Johnston only twice, in two videos his captors posted on the Internet.

In the first, he condemned Britain, Israel and the U.S. In the second, he was shown wearing an explosive belt that he said would be detonated should anyone try to rescue him.

On Wednesday, Johnston said he was forced to read a prepared script and he didn't know if the belt was real. "To be honest, they hold all the cards in that situation, those guys, and I just decided that nobody takes these kind of videos very seriously."

After being held for a month in relatively good conditions, Johnston was confined to "a weird dark world with all the shutters drawn," and guarded by gruff kidnappers headed by a man he knew as Abu Khaled.

Johnston described them as a group focused less on the Palestinian conflict with Israel than on international jihad and on "getting a knife into Britain in some way."

For one 24-hour period he was chained to the wall. When he got sick from the food his captors gave him, they changed his diet to a simple one of eggs, bread and cheese.

Johnston said he spent most of his time with one man, "a strange guy who barely spoke to me for days and would just glare at me and fly into rages at tiny things — a door slamming or whatever — and then at other times, once a fortnight, he would come across completely different and friendly, especially if he thought it might be coming to an end, the whole kidnapping."

At one point, the guard invited Johnston to watch television and he saw his father at a news conference calling for his release.

The Army of Islam was one of the groups responsible for capturing an Israeli soldier, Cpl. Gilad Shalit, a year ago. Shalit remains captive in Gaza, but Johnston said he heard no mention of the soldier.

Israeli Prime Minister Ehud Olmert released a statement welcoming Johnston's release and calling for freedom for the soldier as well.

Israel's Channel 10 TV showed video of a masked Palestinian who it said was a spokesman for the Army of Islam, saying Shalit had been turned over to Hamas. Both Hamas and the Army of Islam denied the report.

While Johnston was in captivity, Gaza erupted into fierce fighting between Fatah and Hamas that ended with Hamas' takeover of the entire coastal territory in mid-June.

"There was something uniquely depressing ... about being kidnapped and lying in your hideout when the forces of law and order are killing each other in a very intense way in the streets around instead of actually looking for you," he said.

The Hamas victory made the kidnappers noticeably nervous, because Hamas has proclaimed "a huge law and order agenda," Johnston said.

He said his kidnappers weren't violent until the final hours of his captivity. They burst into his room and told him to get dressed, he said, and one of the men said, "You're going to Britain."

What followed, Johnston said, was "a terrible, highly charged ride into the center of Gaza" as his captors drove through Hamas roadblocks to turn him over.

At that point, the kidnappers were "wild eyed" and "hysterical," he said at the Jerusalem news conference. "They started having a go at me. They were slamming my head."

After his release, Johnston was immediately surrounded by armed men from Hamas and hustled off to a news conference with Ismail Haniyeh, who heads the Hamas regime in Gaza. Accompanied by British diplomats, he left Gaza and traveled to Jerusalem.

"It is just the most fantastic thing to be free," Johnston said.

He ruled out returning to his reporting job in Gaza.

"I spent three years covering Gaza as a correspondent and I spent four months in solitary confinement there, and I feel — enough already with Gaza. You know, maybe I'll go back when it's a member of the EU" — the European Union, he said.