NOUAKCHOTT, Mauritania — 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 how he was 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 fired generals. The statement also restored the jobs of the other three generals.

President Sidi Ould Cheikh Abdallahi was being held by renegade soldiers at the presidential palace in 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.

In Washington, State Department spokesman Gonzalo Gallegos condemned the coup, adding that "this was a constitutional government, democratically elected."

Gallegos said that officials in the U.S. embassy in Nouakchott believe that all U.S. citizens in Mauritania have been accounted for.

The continentwide African Union also condemned the coup and said it would send the head of its peace and security council to the Mauritanian capital later this week. The AU's top official, Jean Ping, said in a statement the organization "demands the restoration of constitutional legality."

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, 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 Abdallahi angered Aziz and his supporters by opening a dialogue with Islamic hard-liners who had been accused of having links with an al-Qaida-affialiated terror network believed operating in northern Africa. Abdallahi also released from prison several alleged terror suspects.

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

The country's latest political crisis began in May after Abdallahi appointed 12 ministers, some accused of corruption and all of whom had held prominent posts in the government of 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 satellite television station Al-Jazeera by telephone that many people supported Wednesday's takeover. 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 at home or in their hotels for the rest of the day. French Foreign Ministry spokesman Romain Nadal said measures have been taken to protect the safety of French citizens in Mauritania.

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 cancel the 2008 Dakar Rally, a famous transcontinental car and motorcycle race that brought pride and foreign currency into the country.

Associated Press writers Todd Pitman and Rukmini Callimachi contributed to this story from in Dakar, Senegal, as well as Jenny Barchfield from Paris, and Maggie Michael from Cairo.