President Muhammadu Buhari has asked the military in Gabon to respect the constitution of the country and democracy.
Mr Buhari’s call followed the failed coup in the oil-rich African country.
The plotters seized control of the national radio station early on Monday morning.
They then broadcast a message saying that President Ali Bongo was no longer fit for office.
However, Gabon security forces killed two suspects in a failed coup attempt in the country and captured seven others on Monday, government spokesperson Guy-Bertrand Mapangou told reporters.
“The military officers in Gabon should understand that the era of military coups and governments in Africa and indeed worldwide, is long gone. Democracy is supreme and the constitutional stipulations on the peaceful change of administration must be respected. That is the only way we can ensure peace and stability not only within the country but also in the region,” said Mr Buhari.
The Nigerian president himself seized power in 1983 in a military coup that toppled a democratically-elected government.
Mr Buhari, then an army general, was also toppled two years after.
In his message on the Gabon attempted coup, Mr Buhari urged military officers with political ambitions should either resign or “face their constitutional role”.
Mr Buhari, who is the chairman of the Economic Community of West African States (ECOWAS) advised the people of Gabon to “remain on the side of peace, security, stability and democracy in their country, the statement by his media aide, Garba Shehu added.