The two journalists were held captive separately for 15 months
Two foreign journalists held captive by militants in Somalia for more than a year have told the BBC of their joy and relief at being freed.
"I'm so happy to be free; it feels like a dream," Canadian Amanda Lindhout said. Her Australian colleague Nigel Brennan said he was still "in shock".
Details of the release are not yet known, but a ransom demand was made.
Somalia has been without an effective government since 1991, and journalists and aid workers are frequently seized.
'Early Christmas present'
Ms Lindhout and Mr Brennan have now been flown to Nairobi in neighbouring Kenya.
Bob Mills, a former Canadian MP who acted as an intermediary for the Lindhout family, told the BBC's World Today programme the news was "a wonderful Christmas present".
He said he did not know if a ransom had been paid.
"I know the Canadian government's position is not to pay ransom," he said, but pointed out that individuals may have done.
Ms Lindhout told the Canadian Broadcasting Corporation she found the conditions of her captivity extremely difficult.
"It was extremely oppressive. I was kept by myself at all times. I had no-one to speak to. I was usually kept in a room with a light, no window," she said.
"I had nothing, nothing to write on or with. I was given very little food. I was allowed to use the toilet exactly five times a day. So basically my day was sitting on a corner, on the floor, 24 hours a day for the last 15 months."
She is reported to have told Canada's CTV that she was physically abused and forced to make calls to media outlets throughout her ordeal, as her captives wanted a ransom to be paid quickly.
"There were times that I was beaten, that I was tortured," she said.
A man purporting to be one of the kidnappers told AFP news agency that a ransom of $1m (£600,000) had been paid.
Somali MP Ahmed Diiriye gave very few details about how the release was secured but said the hostages had been handed over by militiamen.
Photojournalist Mr Brennan, who had only been in the country for a week when the kidnapping happened, spoke to the BBC Somali Service just after his release.
"I'm in shock. I've got a million things going on in my brain at the moment, but I think shock is the best way to explain how I'm feeling at the moment," he said.
He told Reuters news agency the pair feared they would be sold to other militants and had been kept apart from each other.
He said both had been "through a pretty rough time".
"Being pistol-whipped is sort of torture, being completely stripped of everything and then locked in a room, no-one to speak to, is a form of torture really."
Somali journalist and interpreter Abdifatah Mohammed Elmi, and their two Somali drivers were also seized at the same time, but they were released in January.
They were taken following a trip to visit displaced people outside Mogadishu.
Earlier this year British journalist Colin Freeman and Spanish photographer Jose Cendon were released after being held by Somali kidnappers for 40 days.