Angry mobs loyal to ousted governor Ismail Khan burned a half-dozen international aid compounds, looted their contents and stoned national army troops sent to keep order Sunday as the newly named provincial governor was welcomed at an ornate palace ceremony in this remote western city.

By nightfall, emergency room doctors said, three to 10 people had died and at least 45 had been wounded, mostly from shrapnel and bullets. Police ordered everyone to stay off the streets after dark, while hundreds of soldiers and police officers were stationed along major streets and outside official buildings.

Flames and smoke rose all afternoon from several charred aid facilities, while gunfire crackled sporadically and military helicopters circled the urban sky. Officials said most foreign staffers from U.N. and other aid agencies had taken refuge in bunkers or had been evacuated to a U.S. military compound. No injuries among them were reported.

Khan, the longtime governor of Herat province and a powerful Islamic militia leader, remained secluded in his home while his replacement, Sayeed Mohammed Khairkhwa, arrived on a special flight from Kabul, the capital 370 miles east, and was greeted by several hundred local officials and tribal elders.

Khairkhwa, who had been Afghanistan's ambassador to Ukraine, was appointed Saturday by President Hamid Karzai, who simultaneously offered Khan a new post as minister of mines and industry. Officials called the switch an effort to bring peace and stability to the region following a month of sporadic violent clashes between forces loyal to Khan, an ethnic Tajik, and troops of a rival ethnic Pashtun militia leader.

Mir Abdul Khaliq, the deputy governor of Herat, said at the welcoming ceremony that Khan had met with provincial officials Saturday night at his home, where he had instructed them to support the central government's decision and to greet Khairkhwa at the airport.

In a brief televised statement Sunday night, Khan said the handover was "part of the natural order." He asked the public to "be patient and maintain security. Do not let anyone rob or loot or burn buildings." But he also criticized army troops, saying they had fired directly into crowds and killed innocent young people.

Khan has so far declined to accept Karzai's offer to become a minister in Kabul, but his swift acquiescence to being replaced as governor, after years as the most dominant figure in western Afghanistan, was seen by Afghan officials and Western diplomats as a significant victory for Karzai's efforts to expand central government control in the weeks before presidential elections set for Oct. 9.

But news of Khan's abrupt removal enraged his supporters in this wealthy and strategically important trading city near the Iranian border. Beginning Saturday night, crowds of men roamed the streets, throwing stones at national army troops and police and shouting slogans against Karzai and the United States. When the delegation of officials from Kabul flew here Sunday to install Khairkhwa in the palace, which has been occupied by Khan for much of the last 25 years, hundreds of Khan loyalists again took to the streets.

Witnesses and soldiers said the mobs broke into offices of the U.N. political mission, the U.N. refugee agency, the World Health Organization, the International Organization for Migration and the U.N. anti-drug office. They said the demonstrators set buildings and vehicles on fire, smashed furniture and stole equipment. Mobs also ransacked the local office of the Afghanistan Independent Human Rights Commission. Officials and soldiers said the crowds blamed foreign forces and agencies for siding with Karzai against Khan.

The former governor has won praise for rebuilding Herat after years of war and undertaking numerous public works, but he has also been criticized by Afghan and international human rights groups for persecuting political opponents, suppressing women's rights and using armed thugs to enforce his will.

"I was sitting in my office when a crowd broke down the doors and windows," said Mohammed Rafi, a member of the human rights commission. "We got a ladder and everyone escaped to a neighboring building. But they burned all the cars and they took everything -- the carpets, the computers, the television."

At the World Health Organization compound Sunday evening, soldiers stood guard while flames were visible in the charred and windowless main building. Two utility vehicles with U.N. license plates sat smashed and blackened in the yard, while hundreds of medicine bottles and other supplies lay scattered on the ground.

Across the street, the compound of the International Organization for Migration, which assists Afghan refugees returning from Iran, was also destroyed. Several buildings were badly charred by fire and surrounded by burned and shattered vehicles.

"These people were very excited and shouting. . . . They broke in and filled cans with gasoline and threw them," said Gul Mohammed, 27, a national army soldier guarding the abandoned facility. "We told them we are Muslims and Afghans and we are here to protect the city, but they wouldn't listen. We did not have orders to shoot, or many of them would have been killed."

In Kabul, Karzai issued a statement saying that the people of Herat appreciated the U.N. assistance and that the violence was "the work of a law-breaking group of individuals who are against the people of Herat and against peace and security."

Khairkhwa, a Herat native, appealed for public support and said he would do his best to bring development and democracy to the region. He also called for an end to the kind of ethnic and political factionalism that contributed to the recent armed violence.

Ismail Khan, left, who was removed as governor of Herat province by Afghan President Hamid Karzai, right, appealed to his supporters to end their violent protests.