A military junta overthrew Mauritania's U.S.-allied president Wednesday, saying it would temporarily rule the Muslim West African nation whose government had recently forged ties with the West and had warned of a growing threat from Islamic militants linked to al Qaeda.

No casualties were reported in the quick takeover, and President Maouya Sidi Ahmed Taya was out of the country when presidential guard troops took control of the national radio and television stations and seized the headquarters of the army chief of staff.

Taya, who took power in a 1984 coup, has allied himself with the United States in the war on terror and cracked down ruthlessly on opponents he accuses of being Islamic extremists. He refused to comment after arriving Wednesday in nearby Niger from Saudi Arabia, where he had attended King Fahd's funeral.

A group of army officers, calling itself the Military Council for Justice and Democracy, announced the coup in a statement. "The armed forces have unanimously decided to put an end to the totalitarian practices of the deposed regime under which our people have suffered," it said.

The junta said it would exercise power for as long as two years to allow time for the building of "open and transparent" democratic institutions. Taya, who is in his sixties, was expected to remain in Niger temporarily.

The opposition and some international groups have accused Taya of exaggerating the threat of Islamic extremism. He has jailed scores of Islamic activists and members of the army, accusing them of being terrorists or plotting to overthrow him after a 2003 coup attempt.

The United States recently stepped up military cooperation with Mauritania as part of a new counterterrorism initiative in Africa. In June, U.S. Special Forces troops spent three weeks in the country training infantry forces.

In May, the International Crisis Group, a research organization based in Brussels, warned that if Mauritania became closely linked to U.S. anti-terror policy and overreacted to the domestic threat of Islamic terrorism, the move could prove a "very costly mistake."

In the capital Wednesday, most shops and offices remained closed. Heavily armed troops deployed around government buildings and patrolled the streets. The international airport was closed. But hundreds of people celebrated in the streets, saluting soldiers and singing slogans against Taya.

"It's the end of a long period of oppression and injustice," said Fidi Kane, a civil servant. "We are very delighted with this change of regime."

African leaders, however, condemned the power grab, saying the days of autocracy and military rule must give way to democracy across the continent.

"The days of tolerating military governance in our subregion or anywhere are long gone," said Femi Fani-Kayode, a spokesman for Nigeria's government. "We insist on democracy."

The Bush administration also condemned the takeover in the nation of 3 million people. A State Department spokesman called for a "peaceful return to order under the constitution and the established government." The State Department warned Americans in Mauritania to remain at home, but the U.S. Embassy was open.

U.N. Secretary General Kofi Annan also condemned "any attempt to change the government of any country unconstitutionally," according to a statement.

Oil was recently discovered off Mauritania's Atlantic coast, and the country is expected to begin pumping crude early next year.

Islamic leaders in Mauritania have criticized Taya for opening diplomatic relations with Israel in 1999 and for breaking ties with Iraq after he supported Saddam Hussein in the 1991 Persian Gulf War. Some Islamic opponents have been accused of collaborating with the Salafist Group for Call and Combat, an Algerian group on the U.S. list of terrorist groups.

Staff writers Ann Scott Tyson and Robin Wright in Washington contributed to this report.

President Maouya Sidi Ahmed Taya, shown in an image from a 2003 video, had cracked down on opponents he accused of being Islamic extremists.