Security forces have been deployed in the capital and will remain there over the coming days in order to maintain order.
PIC: The entrance to Gabon's presidential palace in Libreville. (AFP file photo)
A group of soldiers sought to take power in Gabon on Monday while the country's ailing president was abroad, but the government declared the bid had failed and the rebels had been arrested.
Soldiers burst into state radio offices at dawn and called on the public to "rise up" after President Ali Bongo suffered a stroke last year while out of the country.
Shots were heard around state broadcasting headquarters in Libreville, capital of the oil-rich West African nation, at about the same time as the message was read at 6:30 am (0530 GMT).
But within a few hours, government spokesman Guy-Bertrand Mapangou told AFP: "Calm has returned, the situation is under control."
Of the five who entered the radio station, "four have been arrested and one is on the run," according to Mapangou.
Security forces have been deployed in the capital and will remain there over the coming days in order to maintain order, he said.
The elite Republican Guard was deployed around the building and armoured vehicles blocked access to the area, an AFP correspondent saw.
Mapangou added that the gunfire earlier was to control a crowd.
The dramatic developments came as Bongo is living at a private residence in the Moroccan capital Rabat after suffering a stroke. He made a televised speech on New Year's Eve but has not been in the country since October.
Earlier, Gabon soldiers on state radio called on the people to "rise up" and announced a "national restoration council" would be formed. (Credit: AFP/YouTube)
A message was read on state radio by a person who identified himself as Lieutenant Ondo Obiang Kelly, the deputy commander of the Republican Guard and head of a previously unknown group, the Patriotic Youth Movement of the Gabonese Defence and Security Forces (MPJFDS).
He announced a "national restoration council" would be formed "to guarantee a democratic transition for the Gabonese people".
The movement "calls on all young people from forces for the defence and security and Gabonese young people to join us," the officer said.
Three soldiers wearing the green beret of the Republican Guard, two of them carrying assault rifles,were visible on a video of the speech circulating on social media and authenticated by AFP.
"We cannot abandon our homeland," the officer said.
"The eagerly awaited day has arrived when the army has decided to put itself on the side of the people in order to save Gabon from chaos.
"If you are eating, stop; if you are having a drink, stop; if you are sleeping, wake up. Wake up your neighbours... rise up as one and take control of the street," he said.
Morocco's King Mohamed VI (L) visited Gabon's President Ali Bongo at the military hospital in the capital Rabat. (Credit: AFP/Moroccan Royal Palace)
'A difficult period'
The officer called on the people of Gabon to occupy public buildings and airports throughout the country.
The 59-year-old Bongo has not been back to Gabon since he fell ill in Saudi Arabia on October 24.
In his absence, the Constitutional Court transferred part of the powers of the president to the prime minister and the vice president.
The statement read out on Monday attacked the arrangement set in place during Bongo's absence as "illegitimate and illegal."
On December 31, Bongo addressed the country for the first time since falling ill, saying in a recorded speech from Morocco that he had "been through a difficult period."
The MPJFDS considers the speech "shameful" for a "country (which) has lost its dignity", the officer said in the speech on state delivered Monday.
The Bongo family has governed the equatorial African nation for five decades.
Bongo took over from his father Omar, who took office in 1967 and gained the reputation of a kleptocrat -- one of the wealthiest men in the world, with a fortune derived from Gabon's oil wealth.
He was also a pillar of "Francafrique" -- a now much-contested strategy by which France bound itself to its former African colonies through cronyism, often tainted with corruption and rights abuses.
Ali Bongo was elected head of state after his father's death in 2009.
He was narrowly re-elected in 2016 following a presidential poll marred by deadly violence and allegations of fraud.
The African Union said it "strongly condemns" the coup attempt and reaffirmed its "total rejection of all unconstitutional change of power".