NAIROBI, KENYA, DEC. 31 -- Somali President Mohamed Siad Barre was forced to flee his palace in Mogadishu today in the wake of an armed assault by hundreds of insurgents seeking an end to Barre's 21-year reign.

The pro-American president, who has been besieged by rebels on three fronts in recent weeks, sought refuge with his closest advisers in an old barracks at a military airfield near the international airport several miles outside the capital, according to Western observers' reports reaching Nairobi this evening.

Italian radio reported that hundreds of people, including both soldiers and civilians, had been killed in the capital. Somali state radio, monitored by the BBC, quoted Prime Minister Mohamed Hawadie Madar as saying rebels had been beaten back from the district where the palace is located, and a rebel spokesman in London reported that insurgents held five of Mogadishu's 13 districts, Reuter reported.

In Washington, State Department spokesman David Denny called the situation in Mogadishu "very confused." He said today's fighting "seemed to evolve out of government attempts to confiscate weapons from suspected opponents in neighborhoods near the presidential compound."

The crisis in Mogadishu -- reportedly highlighted by the nearly around-the-clock crackle of machine-gun fire and roar of rocket-propelled grenades -- appeared to represent a climactic chapter in a six-year armed struggle against the rule of Siad Barre, whose government has been accused by dissidents and international human-rights observers of widespread abuses against civilians and political opponents. The insurgency has been waged by a number of loosely allied rebel groups organized along ethnic lines rather than ideology.

Refugees were said to be streaming south from Mogadishu today in a bid to escape heavy fighting in the northern suburbs and city center which has claimed scores of lives in the last week.

Human rights workers contacted today said many civilians have been killed in recent days, including at least 61 who allegedly were arrested and shot to death in a mass execution by government soldiers loyal to Siad Barre who had conducted house-to-house searches for rebel sympathizers in Mogadishu.

While Siad Barre's government appeared to be in disarray, there was no immediate indication that the president, whose exact age is unknown but who is reported to be in his early seventies, intended to flee the country or to give up power, according to these Western observers.

They said the government, including members of Siad Barre's immediate family, appeared to be split between a faction that favors negotiations with the rebels and another that is pushing for a last-ditch, all-out military counteroffensive against the insurgents.

At the heart of the conflict is an intense rivalry among Somalia's half-dozen major clans or ethnic groups. Siad Barre is a member of the Marehan clan, which accounts for barely 1 percent of Somalia's 8 million people. After taking power in a 1969 military coup, Siad Barre consolidated his rule by deftly playing off the nation's majority clans against each other. He has endured many challenges to his rule only to emerge stronger than before.

But over the last six years, the government has faced growing opposition, the most powerful originating among the Isack clan in northern Somalia, where rebels of the Somali National Movement have effectively ousted the government. In 1988, in the northern city of Hargeysa, hundreds of civilians were killed when government aircraft bombed the city and virtually destroyed it. The attack galvanized popular opposition to the Siad Barre regime.

A second guerrilla group, the Somalia Patriotic Movement, predominantly made up of the Ogadeni clan, operates in southern Somalia. The group currently besieging the capital, the United Somali Congress, generally comprises members of Somalia's majority clan, the Hawiye, who hail from the nation's central region.

Until this year, the three main rebel groups operated independently, but last summer the factions agreed to work in concert to topple Siad Barre.

Western analysts said the success of the Hawiye rebels in Mogadishu, where they have been aided by Isack and Ogadeni sympathizers, indicates both the effectiveness of the rebel alliance and the shakiness of Siad Barre's forces. Members of the Somali military, particularly Hawiye and Ogandeni troops, have defected in growing numbers during recent weeks, analysts said.

The capital's months-long descent into anarchy accelerated this month when insurgents from the United Somali Congress stepped up attacks on government installations, including terrorist bombings of the city post office and police stations. Last week, rebels were blamed for an attack on an airfield south of the city during which several military aircraft were destroyed.

The BBC said the latest round of fighting broke out Sunday after armed attackers broke into a warehouse and killed a senior army officer. At least 20 people were killed Sunday and more than 50 wounded, the BBC said.

As a result of the increasing violence, Western embassies and international aid organizations in Mogadishu have ordered all nonessential employees to leave the country.

Siad Barre's government was closely aligned with Cuba and the Soviet Union until the late 1970s when, after a war between Somalia and Ethiopia over control of the Ogaden desert, Siad Barre turned to the West for arms and aid.

The government, which is more than $3 billion in debt, steadily has lost favor among most Western nations as an aid recipient in recent years. The United States, which gave Siad Barre's administration as much as $100 million in annual economic and military aid in the early 1980s, sent less than $9 million last year as superpower rivalries diminished and reports of disorder and human rights offenses in Somalia increased.

Faced by the rebel threat, starved for foreign aid and stung by public denunciations of his rule by dissidents demanding his resignation, Siad Barre in recent months signaled a willingness to open the Somali political system to more political parties and to hold national elections, which were scheduled for Feb. 1. Many observers said the changes were too little and too late to stave off the growing challenge to Siad Barre's reign.

Siad Barre's elite Marehan bodyguards -- known as the Red Hats -- reportedly are conducting searches for rebel sympathizers and allegedly singling out and shooting Hawiyes, Isacks and Ogadenis.

Western observers said they fear a spree of revenge attacks against members of Siad Barre's Marehan clan if the rebels seize control of the city.

Analysts said the rebels appeared to have no clear agenda for the country if they take power.

"I think, for now, they are just concentrating on getting rid of Siad Barre," said Rakiya Omaar, a Somali who is executive director of Africa Watch, a London-based human-rights group. "That is their main preoccupation."

Population: 6,654,254 (1990 estimate)

Area: 246,300 square miles, slightly smaller than Texas.

People: Somalis share a common religion, Islam, and a common language, but interclan rivalry has led to economic and political divisions, particularly between northerners and southerners.

Economy: The country remains one of the world's poorest. The economy is largely undeveloped and there has been little real growth in recent decades. The bulk of foreign exchange comes from livestock and livestock-related products.

History: Divided into French, British and Italian sectors at the end of the 19th century, Somalia was partially reunited in 1960 when British Somaliland and the Italian-administered trust territory merged to form a republic. A coup led by Mohamed Siad Barre in 1969 restructured the government along socialist lines. Following an unsuccessful attempt to conquer a heavily-Somali region of Ethiopia, Barre broke off relations with Cuba, expelled thousands of Soviets and turned to the West for aid 1980. The United States has been his closest ally since the late '70s.

Politics: Three loosely coordinated rebel groups are fighting the government for the control of the country: the Somali National Movement in the north, the United Somali Congress in the center and a small insurgency active in the south. All have rejected calls for negotiations in the past month.

SOURCES: Political Handbook of the World, 1990; Agence France Presse