The US is funding a coalition of Somali warlords who earlier this year battled Islamic groups in Mogadishu, Somali President Abdullahi Yusuf has said.
Mr Yusuf's spokesman said the funding was fuelling Somalia's civil war.
At least 70 people were killed in the worst violence seen in the Somali capital for several years, when the two groups clashed in March.
US officials refused to comment directly but one said they did not want terror to take root in the region.
Somalia has not had an effective national authority for 15 years.
Reports that the US was operating in Somalia have been circulating for some time, but this is the first time someone so senior has commented on them.
Mr Yusuf was elected in 2004 by MPs sitting in Kenya, but his rule has been opposed by several of the warlords who earlier this year formed the Alliance for the Restoration of Peace and Counter-Terrorism, to take on the Islamic Courts militia.
The US was using the warlords, most of whom are also MPs, to try to capture al-Qaeda members who are being protected by Islamic clerics in Mogadishu, President Yusuf told the AP news agency.
"But the Americans should tell the warlords they should support the government, and co-operate with the government.
"We are the legitimate government, and we will help you fight terrorism," he said.
The US had seen President Yusuf as an ally in Washington's self-declared war on terror.
The president had fought Islamic groups when he led Somalia's region of Puntland.
The US has set up a military base in neighbouring Djibouti to tackle the Islamic militants who have struck in East Africa - many of whom allegedly have links to Somalia.
The US has previously refused to comment on reports that it has had Islamic leaders kidnapped in Mogadishu and flown abroad for questioning.
US State Department spokesman Sean McCormack said he was not sure why President Yusuf made the latest comments.
"It's a real concern of ours, terror taking root in the Horn of Africa," he said.
"We don't want to see another safe haven for terrorists created."
Somali government spokesman Abdirahman Dinari told Reuters news agency that the US was indirectly fuelling the civil war.
"The warlords, through US support, have caused so many deaths of innocent civilians in the recent fighting in Mogadishu," he said.
The warlords - Mohammed Deere, Mohammed Qanyare and Bashir Rageh - and their business allies control large parts of Mogadishu and, crucially, the airstrips around the capital.