LIBREVILLE, Gabon (AP) — Gabon’s government thwarted an attempted military coup on Monday, retaining control of the oil-rich West African nation 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.

A curfew was imposed over the capital, Libreville, and the internet was cut. The city on the Atlantic Ocean coast was being patrolled by military tanks and armed vehicles.

Earlier Monday a soldier who identified himself as Lt. Obiang Ondo Kelly, 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, sub-Saharan Africa’s third-largest oil producer, 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.

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 African Union also affirmed its support for the Bongo government.

“The African Union strongly condemns the coup attempt this morning in Gabon,” the head of the African Union Commission, Moussa Faki Mahamat, said on Twitter. “I reaffirm the AU’s rejection of all anti-constitutional change.”

In his brief New Year’s address, the 59-year-old Bongo declared that the country was “indivisible” and acknowledged his health problems without giving details. “A difficult period,” he called it, and a challenge that he surmounted “thanks to God.” He promised to put all of his efforts into improving the daily quality of life for Gabon’s people.

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, and he continues to call himself the country’s real president.

In this image from TV, a soldier who identified himself as Lt. Obiang Ondo Kelly, commander of the Republican Guard, reads a statement on state television broadcast from Libreville, saying the military has seized control of the government, Monday Jan. 7, 2019. The statement said Soldiers from Gabon's Republican Guard have launched a coup "to restore democracy" in the West African country, while imposing a curfew in the capital, and the internet has been cut. No violence has been reported and President Ali Bongo has been out of the country since October amid reports that he had a stroke.(Gabon State TV via AP)