A United Nations official seized by Somali gunmen in a row over UN debts has been set free by his kidnappers.
Prime Minister Ghedi wants to apologise for Mr McCarthy's ordeal
US citizen Robert McCarthy was held by a gang hired by a businessmen who claimed the UN owed him money.
Somali PM Ali Mohammed Ghedi told the BBC some $20,000 (£11,400) was paid by transitional government negotiators to secure Mr McCarthy's release.
This was the amount owed to the unnamed businessman for contracts completed seven years ago, he said.
Mr McCarthy had been assessing the effects of drought when abducted.
The UN Children's Fund worker was held for 24 hours near Afmadow in the Lower Juba region.
The negotiators - led by Industry Minister Abdi Mohamed Tarah - decided to pay the money after seeing documentation about unpaid work completed by the businessman for the UN, Mr Ghedi said.
The prime minister added that he hoped to apologise personally to Mr McCarthy for his ordeal.
Somalia has had no functioning central government since 1991 and rival warlords have divided the country between them.
The UN says Somalia is badly hit by the Horn of Africa drought, with some 2m people needing urgent food aid.