In an overnight television announcement, a dozen senior officers declared the election results were cancelled, borders were closed and state institutions were dissolved. They said they represented all Gabon's security and defense forces.
"President Ali Bongo is under house arrest, surrounded by his family and doctors," they said in a statement read out on state TV.
Bongo's son and close adviser Noureddin Bongo Valentin, his chief of staff Ian Ghislain Ngoulou as well as his deputy, two other presidential advisers and the two top officials in the ruling Gabonese Democratic Party (PDG) "have been arrested," a military leader said.
The officers, calling themselves The Committee of Transition and the Restoration of Institutions, said Gabon was "undergoing a severe institutional, political, economic, and social crisis," and said the Aug. 26 election was not transparent or credible.
The opponents say the family has done little to share the state's oil and mining wealth with its 2.3 million people.
Gunfire had been heard briefly in Libreville after the statement announcing the ousting of Bongo, but the streets were largely calm before celebrations erupted. Later, police officers fanned out to guard major city intersections.
There was no immediate comment from Gabon's government.
Bongo made his first public appearance, while under house arrest after Wednesday's coup attempt, speaking via video, and called on the world "to make noise" to support him.
Bongo said: "I'm to send a message to all the friends that we have all over the world to tell them to make noise, to make noise."
The video message was released on behalf of the President’s Office by BTP Advisers, a communications firm that helped the president with polling for this week's election.
He said he was under house arrest and that his wife and son were in a different place.
"I am in the residence, nothing happening, nothing is happening. I don't know ... what's going on," he added.
Hundreds of people took to the streets of the capital Libreville to celebrate in the morning following the overnight announcement, which appeared to have been filmed from the presidential palace, according to the television images.
If successful, the coup would be the eighth in West and Central Africa since 2020. The latest one, in Niger, was in July. Military officers have also seized power in Mali, Guinea, Burkina Faso and Chad, erasing democratic gains since the 1990s.
Bongo, 64, was last seen in public casting his vote on Saturday. He had appeared in public before the election looking healthier than previous rare and frail television appearances following his stroke in 2019.
French Prime Minister Elisabeth Borne said France, Gabon's former colonial ruler, was following the situation closely.
The coup creates more uncertainty for France's presence in the region. It has about 350 troops stationed in Gabon. French forces were kicked out of Mali and Burkina Faso after coups there, amid a wave of anti-French sentiment, and Niger's coup leaders have also revoked military agreements with France.
China's foreign ministry called for the situation in Gabon to be resolved peacefully and said the personal safety of Bongo, who visited China in April, should be ensured.
Russia's foreign ministry also said it was worried about the situation and hoped for stabilization.
Information for this report came from Reuters, AFP and The Associated Press.