South African troops rumbled into this mountain kingdom at dawn Tuesday to quell weeks of anarchy. They secured military bases and the royal palace after heavy fighting, the South African military said.

Battles with rebellious Lesotho soldiers continued into the afternoon, and at least three South African soldiers were killed and 11 wounded, not seriously, the military said in Pretoria.At the border, supporters of the rebel troops set a barricade afire and taunted the South Africans as they crossed into Lesotho, bringing attack helicopters, mortar units and armored personnel carriers.

The action - South Africa's first major post-apartheid military intervention - follows weeks of opposition party demonstrations over allegations of election-rigging and an army rebellion that effectively paralyzed the government.

Lesotho, an impoverished kingdom slightly smaller than Maryland with a population of 2 million people, is surrounded by South African territory and is dependent on its neighbor's economy. The intervention follows fruitless efforts by South African mediators over the weekend to bring the government and opponents together in talks.

Believing a coup was imminent, Lesotho Prime Minister Pakalitha Mosisili called on regional powers to intervene, said Mangosuthu Buthelezi, South Africa's home affairs minister.

Tuesday, protesters firebombed government buildings, looters rampaged through downtown and cars with South African license plates were stoned in the wake of the military intervention. Whole shopping centers were gutted by fire, and smoke drifted from many parts of the capital, Maseru.

The 60 to 70 American citizens who live in Maseru were told to stay indoors, U.S. Ambassador Katherine Peterson said. About 300 Americans live in Lesotho.

A heavy firefight raged at a military barracks near the capital's airport, where mortar explosions were also heard. Fifteen armored vehicles equipped with cannons came to reinforce the South Africans.

An Associated Press reporter and photographer were pinned down inside the barracks area during the battle.

Officials said the South African force secured Lesotho military headquarters, the main air force base, the central business district and the neighborhood where most diplomats and Cabinet members live.

The South Africans met strong resistance in the morning at the royal palace, at a dam in the central part of the country and at two military bases, said a South African military spokeswoman, air force Lt. Col. Laverne Machine.

"Rebel soldiers at the dam put up a strong fight, and the contact was a severe one," she said. "The rebels also suffered heavy casualties."

The South African troops faced anti-aircraft and small-arms fire at the military bases, another spokesman, Maj. Ben van Zyl, said. Rebel soldiers were arming civilians with assault rifles.

She said 200 soldiers from Botswana were expected later in the day to join the 600 South African troops already in Lesotho.

King Letsie III was safe and being protected by South African soldiers, Machine said.

The military said the besieged Lesotho government had sought intervention by the Southern African Development Community, which South Africa chairs.

"The aim of the intervention is to restore stability as quickly as possible and to withdraw from the kingdom of Lesotho as soon as this has been achieved," it said.

Under apartheid, South Africa's rulers sent troops across its borders to Angola and Namibia to take part in wars and to pursue government opponents, particularly in Lesotho and Botswana. But since all-race elections in 1994, South Africa had stuck to a policy of peaceful mediation in African conflicts.