A gay couple jailed in Malawi after getting engaged have been pardoned by President Bingu wa Mutharika.
Mr Mutharika, speaking as UN chief Ban Ki-moon visited his country, said he had ordered their immediate release.
Steven Monjeza and Tiwonge Chimbalanga were given 14-year jail terms earlier this month after being convicted of gross indecency and unnatural acts.
The case has sparked international condemnation and a debate about homosexuality in the country.
Mr Ban hailed the president's decision as "courageous".
"This outdated penal code should be reformed wherever it may exist," he said.
The BBC's Karen Allen, in Lilongwe, says Mr Ban is trying to put pressure on parliamentarians to reform anti-homosexuality laws that date back to colonial times.
'Culture of hate'
Correspondents say Malawi is a deeply conservative society where religious leaders equate same-sex liaisons with Satanism.
Mr Mutharika, who has in the past dismissed homosexuality as alien, said he had set them free on humanitarian grounds.
"In all aspects of reasoning, in all aspects of human understanding, these two gay boys were wrong - totally wrong," he said after meeting Mr Ban.
"However, now that they have been sentenced, I as the president of this country have the powers to pronounce on them and therefore, I have decided that with effect from today, they are pardoned and they will be released."
Monjeza, 26, and Chimbalanga, 20, were arrested in December 2009 after celebrating their engagement. They have been in custody ever since.
Their lawyers say the two men are likely to be freed by Monday.
Our correspondent says there are plenty of people who were not sorry to see the men go to jail, many of whom will be slightly puzzled at the president's announcement.
Gift Trapence, from the campaign group Centre for the Development of People, welcomed the decision.
"We're very happy and we praise the president for his maturity, but there is still a long way to go to end the culture of hate," he said.
Aid donors and human rights groups have been putting pressure on his government to respect the rights of minority groups.
The UK government, Malawi's biggest donor, said it was dismayed by the sentencing, and the US labelled it a step backwards for human rights.
On Saturday, British popstar and Aids campaigner Sir Elton John wrote an open letter to Mr Mutharika in the UK's Guardian newspaper pleading for the release of the pair.
"Their trial and harsh sentencing will have a perilous effect on our continuing efforts to combat Aids in Malawi and potentially reverse the gains we have achieved," he said.
The two men were convicted under a law dating back to colonial rule by Britain.
Many of Britain's former colonies have similar laws outlawing homosexuality; India overturned its anti-homosexuality law last year.
In Uganda, MPs are debating whether to strengthen the laws to include the death penalty for some gay people - a move which has infuriated Western governments and rights campaigners.