TAKORADI, Ghana — Holed up in a bunker under his residence, Ivory Coast’s strongman, Laurent Gbagbo, negotiated the terms of his potential surrender on Tuesday, as opposition forces closed in, his generals called on their forces to lay down their arms and French and United Nations negotiators demanded that he officially renounce control of the country.

It was the culmination of a four-month standoff that has underscored both the strengths and limits of international diplomacy. For months, Mr. Gbagbo has refused to step down after losing a presidential election last year, angrily defying global condemnation and hard-hitting sanctions as his nation spiraled back into civil war.

In the end, it came down to force. The international stance, taken by African and Western countries alike, greatly weakened Mr. Gbagbo’s ability to govern. But his willingness even to discuss the terms of his exit came only after opposition forces swept across the country and France and the United Nations entered the fight, striking targets at his residence, his offices and two of his military bases in what they called an effort to protect civilians.

On Tuesday, a day after the international attacks, France’s foreign minister, Alain Juppé, said at a Parliament hearing that French negotiators were helping to broker Mr. Gbagbo’s surrender, demanding that he sign a document formally recognizing Alassane Ouattara, the man who won the election, as the country’s legitimate president. The United Nations secretary general, Ban Ki-moon, had backed the French terms, Mr. Juppé said.