Freeman, 39, is the chief foreign correspondent for the Sunday Telegraph. He was held with Jose Cendon, a Spanish photographer working for news agency AFP.
The pair were in the country to investigate the outbreak of Somali pirates plaguing the Gulf of Aden.
According to the Daily Telegraph, which carries a personal account by Freeman of his experience, the pair were seized by their own bodyguards on the way to an airport after completing their assignment.
Freeman said the pair were held in caves in a mountain range to the southwest of the city of Boosasso by the gang, who yesterday handed them over to a group of clan elders who were the middlemen for the final handover.
Freedman wrote in the Telegraph: "Occasionally, there would be news that the talks to free us were progressing well, but more often the word was of endless complications.
"Sometimes the kidnappers would threaten to harm us, and on one occasion they cocked a Kalashnikov rifle at my head and made a convincing pantomime of my imminent execution."
Telegraph Media Group said it had worked closely with the journalists' families to help secure their release. It praised Nicolas Martin Cinto, Spain's ambassador to Nairobi, for his help.
Somalia is one of the most dangerous places in the world for working journalists. In 2005 BBC producer, Kate Peyton, also 39, was shot dead while making a series of reports in the Somali capital, Mogadishu.