Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

LIBREVILLE, Gabon — An attempted military coup was thwarted in oil-rich Gabon after two plotters were killed and other army officers were arrested, the government said.

Authorities regained control of state broadcasting offices and a major thoroughfare in the capital, Libreville, which were the only areas taken over by the officers, government spokesman Guy-Betrand Mapangou told Radio France International.

He said five army officers who took over state radio were arrested. Two other coup plotters were killed when security forces took over and freed some hostages, according to a presidential statement reported by RFI.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Security forces patrol Libreville on Monday. Steve Jordan / AFP - Getty Images

Earlier Monday a soldier who identified himself as Lt. Kelly Ondo Obiang, commander of the Republican Guard, read out a statement saying the military had seized control of Gabon's government in order to "restore democracy." He was flanked by two other soldiers holding weapons; all were dressed in camouflage uniforms and green berets.

Those soldiers have been taken into custody and President Ali Bongo's government remains in control, government spokesman Mapangou said.

Bongo, who has been in power since 2009, has been out of the country since October amid reports that he had a stroke. He recently addressed the country in a New Year's message that was filmed in Morocco, where he has been receiving medical treatment.

Gabon has been ruled for more than half a century by Bongo and his father, Omar, who died in 2009. Critics have accused the family of profiting from the country's natural resources while not investing enough in basic services for the population of more than 2 million. About one-third of the population lives below the poverty line, according to the World Bank.

Gabon is sub-Saharan Africa's third-largest oil producer. Bing Maps

As news of the coup reverberated through the international community, U.N. Secretary-General Antonio Guterres condemned the attempted coup and called on all in the country to follow its constitutional laws, spokesman Stephane Dujarric said.

The French-educated Bongo, who was the country's defense minister before becoming president, narrowly won re-election in 2016 in a vote opposition rival Jean Ping claimed was plagued by irregularities. The election trigger violent protests.

Gabon's economy was long buoyed by oil revenues, much of which went to a moneyed elite while most of the county's 2 million people live in deep poverty. However, a sharp drop in oil output and prices in recent years has squeezed revenues, raised debt and stoked discontent.

In Libreville, expensive Western hotels overlook the Atlantic Ocean to the west and the capital's hillside shanties to the east.