The bloodless coup reflected the internal struggle over how to manage this desperately poor desert nation that straddles the Arab and African worlds and is Africa's newest, if small-scale, oil producer.
Troubles began early Wednesday when President Sidi Ould Cheikh Abdallahi fired the country's top four generals, reportedly for supporting lawmakers who had accused him of corruption and disagreed with his reaching out to Islamic militants that previous governments cracked down on.
Troops seized state radio and television and announced the formation of a new "state council" led by the commander of the presidential guard, Gen. Mohamed Ould Abdel Aziz, who was one of the four fired generals.
The junta issued no statement on the motivation for the coup or their plans. Sidi Mohamed Ould Maham, a lawmaker who supported the coup, said leaders would appoint a 14-member interim government to govern for six months and hold elections.
Abdallahi was detained by presidential guard units and held at the palace compound, a grandiose, whitewashed complex in the sandy coastal capital, Nouakchott. His spokesman, Abdoulaye Mamadou Ba, said soldiers also detained Prime Minister Yahya Ould Ahmed Waqef.
"He fired the generals and that is his constitutional right. This is a coup d'etat against democracy. ...," Ba told The Associated Press. "President Abdallahi is the victim of a coup concocted by the army with the connivance of lawmakers in parliament."
Much like the nation's last coup in 2005, the change of power was swiftly condemned by the United States, the European Union and the African Union, which said it would send an envoy to Nouakchott this week.
Last time, the coup was wildly popular in the streets and silently applauded abroad because it ended the 21-year rule of an unpopular dictator, paving the way for the 2007 elections that brought back civilian rule.
The level of popular support is less clear this time, and coup leaders risk real isolation from the international community.
"We condemn in the strongest possible terms the Mauritanian military's overthrow of the democratically elected government of Mauritania," State Department spokesman Gonzalo Gallegos said. "We call on the military to release the president and the prime minister and to restore the legitimate, constitutional, democratically elected government immediately,"
EU Development Commissioner Louis Michel said Mauritania's president and prime minister should be quickly returned to their posts, warning that $241 million in EU aid for Mauritania could be at risk if they are not.
The capital remained calm, and by nightfall traffic was circulating almost normally and shops had reopened. Police supporting the coup kept a close watch to maintain order, even using tear gas to disperse several hundred supporters of the coup leader who were blocking streets.
Amal Cheikh Abdallahi, the president's daughter who serves as an official spokeswoman for his administration, said she was "extremely worried about my father."
She said that for the past three months, Aziz and other top military commanders had pretended to be the president's ally while simultaneously lobbying politicians in parliament to undertake a no-confidence vote in June that went against her father's administration.
Political alliances have been shifting in Mauritania, creating a complex power struggle pitting military commanders led by Aziz against Abdallahi, who has allies who served in the former regime of President Maaouya Sid'Ahmed Ould Taya, who was overthrown in 2005.
Aziz helped mastermind that coup and Abdallahi won the election that followed two years later with Aziz's backing.
But Aziz and other top officials expressed dismay when Abdallahi opened a dialogue with Islamic hard-liners accused of ties to an al Qaeda-affialiated network operating in northern Africa. Abdallahi also released several terrorism suspects from prison soon after taking power.
One of only three Arab League countries to have diplomatic relations with Israel, Mauritania was rocked in late 2007 and early 2008 by a series of attacks that included a shootout in front of the Israeli Embassy and the slaying of four French tourists outside the capital. The violence led organizers of the transcontinental Dakar Rally to call off the famous race this year.
Lawmakers also have accused Abdallahi of exhibiting the same dictatorial tendencies as Taya.
The Cabinet was forced to resign in June after parliament members passed the no confidence vote. Lawmakers were angry that Abdallahi had appointed 12 ministers from Taya's inner circle, dashing hopes for a clear break with the past.
Parliament members also took issue with the number of positions the president, a devout Muslim, gave to the Tawassoul party, which represents hard-line Muslims.
In a conciliatory gesture, Abdallahi made sure the new Cabinet he appointed July 10 did not include anyone from Tawassoul. But he still appointed several former Taya loyalists, and this week 49 legislators quit the president's party in protest.
At a news conference Wednesday, legislator Mohamed Yahya Khirchi read a declaration signed by the defectors saying they supported the coup.
"The members of the Mauritanian parliament wish to underline that it was the army that liberated the Mauritanian people from the yoke of the dictatorship of President Taya and it's them again today that are defending the democratic gains we made," Khirchi said.
Abdallahi also drew criticism for using public funds to build a mosque on the grounds of the presidential palace. Lawmakers demanded an investigation into allegations of corruption and misuse of public funds by his wife.
For its part, the junta announced no specific reasons for the coup and its leaders refused to speak with journalists.
Mohamed Mahmoud Ould Mohamedou, a Foreign Affairs Ministry official who is a member of Aziz's extended family, said the coup was fueled by the army's desire to act firmly "against the radical Islamist threat."
Mohamedou complained that Abdallahi freed radicals against his generals' advice and charged that those activists "went on to regroup and led a series of attacks against foreigners."
With a population of 3.4 million, Mauritania 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 2006. The country only produces a minuscule 12,000 barrels a day, said energy analyst Thomas Pearmain at Global Insight in London.