The Supreme Court in Somalia has freed journalist Abdiaziz Abdinur Ibrahim, who was imprisoned for interviewing a woman who alleged she had been raped by security forces.
Abdiaziz Abdinur Ibrahim, 27, and his interviewee were jailed in February after being convicted of offending state institutions.
In early March the woman was freed on appeal, but the journalist, who did not report the story, was held in jail.
The Supreme Court said on Sunday that charges against Abdiaziz Abdinur Ibrahim had been dropped.
Leaving court, Abdiaziz Abdinur Ibrahim said: “I’m very happy that I got my freedom back, I thank those who worked in this process that helped my release including my lawyers.”
The case prompted an outcry from human rights groups and journalists, who said it was politically motivated.
UN Secretary General Ban Ki-moon said he was “deeply disappointed”.
Both the woman and Abdiaziz Abdinur Ibrahim were originally given one-year jail terms.The woman had reported the alleged rape at a police station in Mogadishu and prosecutors alleged she and others had been paid by Abdiaziz Abdinur Ibrahim to lie.
She was convicted after the judge cited disputed medical evidence saying she had not been raped.
Abdiaziz Abdinur Ibrahim, who was detained in January, was accused by police of collecting material for an al-Jazeera media report on rape in camps for displaced people.
He had been working for Somali radio stations and international media but had not been involved in the story in question, the network said.
A new government backed by the UN came to power last September, after eight years of transitional rule.
Somali has seen more than 20 years of conflict which saw clan-based warlords, rival politicians and Islamist militants battle for control of the country.