Mohammed Ali Gedi said: "Egypt, Libya and Iran, whom we thought were friends, are engaged in fueling the conflict in Somalia by supporting the terrorists."
Gedi is facing a no-confidence vote after 18 lawmakers resigned from his administration in disgust, saying it had failed to bring peace.
Two politicians were shot this week, one fatally.
Sheik Hassan Dahir Aweys, leader of the Islamists, denied receiving support from foreign countries and said Gedi was "trying to distract attention from his own troubles".
Jendayi Frazier, US assistant secretary of state, said that both sides in the conflict have "invited in foreign forces" and that "neither the union of Islamic courts nor the transitional federal government can take the high ground".
Speaking from Kinshasa in the Congo she said: "They've all been backed by foreign forces."
The Islamists have rallied their supporters by condemning reports that Ethiopian troops, Somalia's traditional enemy, have entered the country to protect the government.
The government, in turn, accuses the Islamists of receiving weapons from Eritrea.
On Saturday, mourners in Baidoa attended the burial of Abdallah Isaaq Deerow, the transitional government minister who was shot dead on Friday.
Police chief Aadin Biid said nine people have been arrested regarding Deerow's death.
Saturday's funeral for Deerow forced officials to postpone a scheduled vote in parliament on a no-confidence bill against Gedi.