NAIROBI — Famine in parts of Somalia has already killed tens of thousands of people, mostly children, the United Nations said Wednesday in an official declaration of what aid officials describe as the worst humanitarian crisis in the country in two decades.

The famine declaration comes months after U.N. and other aid agencies began sounding the alarm about a devastating drought in the Horn of Africa, where an estimated 10 million people are in need of help. The crisis has been aggravated by civil strife, low rainfall rates not seen in half a century and sharp increases in food prices.

“Somalia is facing its worst food security crisis in the last 20 years,” Mark Bowden, the top U.N. official in charge of humanitarian aid to Somalia, told reporters, adding that an infusion of $300 million is needed in the next two months to help alleviate the crisis.

For nearly two decades, Somalia has grappled with civil war and ineffective governments. Today, a weak and corrupt transitional government, backed by the United States and its allies, is in place, with little ability to address the crisis. Much of its energy is focused on preventing the capital, Mogadishu, from being overtaken by the al-Qaida-linked al-Shabab militia.

In 1992, hundreds of thousands of Somalis starved to death, prompting a U.S.-led peacekeeping force to intervene. Within months, the force was engaged in an intense conflict to uproot Somali warlords. It eventually withdrew after 18 American soldiers were killed in a battle the following year, an incident portrayed in the book and movie “Black Hawk Down.”

This time, the famine is unfolding in the southern Somali regions of Bakool and Lower Shabelle, which are largely controlled by al-Shabab.