A group of soldiers attempted to take power and called in a radio appeal for a popular uprising against ailing President Ali Bongo, who is abroad recovering from a stroke.
Security forces stormed the radio station in the capital Libreville to take it back, killing two rebel troops, arresting their leader and freeing journalists who had been forced to help rebels make their appeal.
"The situation is under control," the presidency statement said.
Six rebel troops earlier Monday burst into the state radio broadcasting station, "neutralising" gendarmes in front of the building before making their broadcast, it said.
Officials earlier said five rebels had entered the building and four had been arrested.
The message was read 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.
He said a "national restoration council" would be formed in the former French colony "to guarantee a democratic transition for the Gabonese people".
UN chief condemns attempted coup
UN Secretary General Antonio Guterres on Monday condemned an attempted coup in Gabon, his spokesman said, recalling that the UN chief opposes unconstitutional changes of power by force.
"The secretary-General has always stood against unconstitutional changes of power, especially by force, and in that light, he condemns the attempted coup that took place this morning in Gabon," said UN spokesman Stephane Dujarric.
Guterres added that calm appears to have returned in Libreville and calls "on all actors to follow constitutional means", added Dujarric.
The UN envoy for Central Africa, Francois Lounceny Fall, who is based in Libreville was closely monitoring the situation and is ready to offer assistance if needed, said the spokesman.
Junior officers have seized the national radio station and other buildings in the African nation's capital. Source: Twitter
Bongo is staying 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 West African country since October.
President Bongo took power in 2009 and is believed to be in Morocco, receiving treatment after suffering a stroke in October.
Mr Bongo sought to put an end to the rumours about his health with a New Year message in which he said he was feeling fine.
President Ali Bongo took over power in 2009. He reportedly suffered a stroke in October and received treatment in Morocco. Source: AP
In his speech on New Year’s, Bongo acknowledged health problems but said he was recovering. He slurred some of his words and did not move his right arm, but otherwise appeared in decent health.
Mr Bongo delivers a speech as he attends Heads of States' Statements ceremony of the COP21 World Climate Change Conference 2015. Source: EPA
The Bongo family has ruled the oil-producing country for nearly half a century. Bongo has been president since succeeding his father, Omar, who died in 2009. His re-election in 2016 was marred by claims of fraud and violent protest.
The attempted overthrow comes as US President Donald Trump announced about 80 US military personnel had deployed to Gabon amid fears of unrest in neighbouring Congo.
'A difficult period'
The 59-year-old Bongo has not been back to Gabon since he fell ill in Saudi Arabia on October 24. It was revealed last month that he had suffered a stroke.
In his absence, the Constitutional Court transferred part of the powers of the president to the prime minister and the vice president.
On December 31, Mr 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 Bongo family has governed the equatorial African nation for five decades.
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.