Army officers upset with government overtures toward Islamic hard-liners staged a coup in Mauritania on Wednesday, overthrowing the first government to be freely elected in this sprawling desert nation in more than 20 years.

The coup in Africa's newest oil producer took place after the president and prime minister fired the country's top four military officials, reportedly for supporting lawmakers who had accused the president of corruption and disagreed with his reaching out to Islamic hard-liners.

A brief announcement read over state television Wednesday said the new "state council" will be led by presidential guard chief Gen. Mohamed Ould Abdel Aziz, one of the four generals fired earlier in the day. The statement also restored the jobs of the other three generals.

President Sidi Ould Cheikh Abdallahi was being held by soldiers at the presidential palace in the capital of Nouakchott, according to presidential spokesman Abdoulaye Mamadouba. Soldiers also detained Prime Minister Yahya Ould Ahmed Waqef, he said.

State radio and television went off air as the coup began and witnesses said soldiers were deployed throughout the capital. No violence was reported.

The United States, the European Union and African powerhouses South Africa and Nigeria condemned the coup, as did the African Union, which said it would send an envoy to the Mauritanian capital later this week.

"This was a constitutional government, democratically elected," U.S. State Department spokesman Gonzalo Gallegos said in Washington.

EU Development Commissioner Louis Michel said Mauritania's president and prime minister should be quickly released and returned to their posts, and warned that euro156 million (US$241 million) of EU aid for Mauritania could be at risk if they are not.

Straddling the western edge of the Sahara desert, Arab-dominated Mauritania, with a population of 3.4 million, has been wracked by more than 10 coups or attempted coups since independence from France in 1960. While most of its people live on about $5 a day, relatively small oil reserves were discovered in Mauritania in 2006.

One of only three Arab League countries to have diplomatic relations with Israel, Mauritania was rocked in 2007 by back-to-back attacks, including one on the Israeli Embassy in Nouakchott and another that killed four French tourists. The government has blamed the attacks on an Islamic terror cell allied with al-Qaida.

Aziz also masterminded the country's last coup in 2005, which was popular locally and ended a long dictatorship. That coup paved the way for the first truly democratic elections in two decades in 2007, which Abdallahi won.

Aziz had backed Abdallahi in last year's vote, but was angered when Abdallahi opened a dialogue with Islamic hard-liners who had been accused of ties to an al-Qaida-affialiated terror network believed operating in northern Africa. Abdallahi also released several alleged terror suspects from prison.

Abdallahi, a devout Muslim, also came under criticism for using public funds to build a mosque on the grounds of the presidency. Lawmakers also demanded an investigation into allegations of corruption and misuse of public funds by his wife.

The country's latest political crisis began in May after Abdallahi appointed 12 ministers, some accused of corruption and all closely tied to former President Maaouya Sid'Ahmed Ould Taya, who was ousted in the 2005 coup.

In June, lawmakers introduced a no-confidence vote against the president and called for his resignation, but Abdallahi survived.

On Wednesday, lawmaker Mohammed Al Mukhtar told the Arab network Al-Jazeera that many people supported the latest coup. He described the government as "an authoritarian regime" and asserted the president had "marginalized the majority in parliament."

The U.S. embassy urged Americans in Mauritania "to exercise extreme caution" and to remain inside for the day, and said all citizens had been accounted for. France also took measures to protect the safety its citizens.

The bloodless 2005 coup, when Col. Ely Ould Mohamed Vall seized power, was widely popular, for many Mauritanians had grown tired of the 21-year rule of former dictator Taya. Vall kept his promise that no junta members would run in the 2007 presidential election, but some in the military were reportedly unhappy at being barred from the race.

The attacks in 2007 prompted French organizers to canceled the 2008 Dakar Rally, a famous transcontinental car and motorcycle race that brought pride and foreign currency into the country.

Mauritania's oil fields were expected to produce up to 75,000 barrels per day when oil was discovered in late 2006. However, analysts said output now was estimated at a miniscule 12,000 barrels a day and the coup would therefore have little effect on global markets.

"Oil production is all offshore and unlikely to be affected by the coup," said energy analyst Thomas Pearmain at Global Insight in London.