Gabon has been partially suspended from the Commonwealth after military commanders carried out a coup ousting President Ali Bongo.
The decision was made by Commonwealth foreign ministers meeting on the margins of the United Nations general assembly.
Leaders called on Gabon to uphold the values and principles of the Commonwealth.
They asked the country to hold credible elections as soon as possible.
Gabon's military ousted Mr Bongo from power shortly after he was declared winner of the 2023 presidential election.
Mr Bongo had been in power in the oil-rich country since 2009, when he succeeded his father who had ruled the country for 41 years.
He was initially placed under house arrest as military leaders took over, but was later freed and given permission to travel abroad for medical check-ups.
The foreign ministers - sitting as the Commonwealth ministerial action group - have requested Gabon guarantee Mr Bongo's safety and that of his family, and said in a statement that they "strongly condemned the unconstitutional removal of the elected government from office".
They said Gabon's suspension was in place "pending the restoration of democracy". It excludes Gabon from all Commonwealth intergovernmental meetings and events, including ministerial and heads of government meetings.
The new prime minister, Raymond Ndong Sima, was installed as interim prime minister in September, after Gen Brice Oligui Nguema, who led the coup against Mr Bongo, became Gabon's transitional president.
Speaking to the BBC, Mr Sima said the country should hold fresh elections within two years.
Commonwealth ministers gave the new leaders of Gabon two years from 30 August 2023 to hold credible elections. They added in the statement that if progress was not made in that time, the country may be removed from the group altogether.
Despite condemnation of the coup from other international leaders in both Africa and the West, civilians appear to have welcomed the change.
Many Gabonese were sceptical about Mr Bongo's decision to stand for a third term. He first came to power in elections 14 years ago following the death of his father, Omar Bongo, who had monopolised the presidency for more than 40 years.
Some also held serious doubts about his capacity to provide effective leadership, after he suffered a stroke in October 2018.
BBC