Laurent Gbagbo's 10-year grip on the Ivory Coast seemed to be in its final hours late Friday, after fighters encircled his residence and the presidential palace.

ABIDJAN, Ivory Coast — Laurent Gbagbo’s 10-year grip on the Ivory Coast seemed to be in its final hours after fighters encircled his residence and the presidential palace and battled to unseat the man who has refused to recognize his defeat in last year’s election.

In the face of a rapid military advance that has swept across the world’s largest cocoa producer and arrived at his doorstep, Gbagbo rejected calls Friday to step down.

His aides said they will never give in, even though nearly 80 percent of the country and large swaths of its largest city and commercial capital, Abidjan, are controlled by an armed group fighting to install the internationally recognized winner of the election, Alassane Ouattara.

“There is no question of ceding,” said Gbagbo’s presidential aide, Fred Anderson. “It’s not up to the international community to impose our leader.”

Unlimited Digital Access. $1 for 4 weeks.

Gunfire, explosions and the sound of heavy weapons could be heard throughout the day in Abidjan as forces supporting Gbagbo’s rival, Alassane Ouattara, who won the presidential election last year, stormed the city after a four-day lightning-fast advance.

The state television station, which had been a loudspeaker for Gbagbo’s refusals to step down since he lost the November election to Ouattara, changed hands amid heavy fighting, and residents throughout the sprawling port city, once a prosperous metropolis, stayed inside their homes.

Diplomats suggested Gbagbo’s struggle to stay in power — despite international condemnation, sanctions and, most recently, the opposition’s advance — was near its end.

“We are moving toward a rapid denouement,” said Choi Young-jin, the United Nations’ special representative in Ivory Coast. “The trend is irreversible. (Gbagbo) has no choice but to step down.”

Gbagbo’s whereabouts were unknown late Friday, but several spokesmen said he had not left the country and had no intention of giving up. Gbagbo had “the upper hand,” adviser Alain Toussaint told the French television network France 24.

Ouattara’s followers said they were not surprised Gbagbo had not surrendered, despite the apparent collapse of his forces.

“With him, the knife must be on his throat,” said Apollinaire Yapi, a spokesman for Ouattara. “He is more afraid of prison than of death.”

Gbagbo, 65, delayed the November election by five years, canceling it every year only to promise, but fail, to hold it the next.

Ouattara’s victory with 54 percent of the vote was recognized first by the country’s electoral commission and then by the United Nations, which pored over thousands of tally sheets before certifying the results.

Ouattara has been recognized by governments around the world, and leaders from U.S. President Obama to French President Nicolas Sarkozy have made personal appeals to Gbagbo to step down.

There were indications Friday that Gbagbo’s hours in power were slipping away.

In the past week, an estimated 50,000 of his fighters in the army and the police have defected, Choi said. Key officers, including generals, have quit. Even his army chief of staff abandoned his post, to seek refuge with South African diplomats.

Despite encountering resistance around crucial buildings, officials in Ouattara’s government said Abidjan was under their control.

But there was some confusion, with one adviser saying that Ouattara’s forces had entered the presidential residence and another denying it.

Ouattara has also begun issuing orders — closing the country’s borders and establishing a curfew — that until recently had been Gbagbo’s strict purview.

Yapi, the Ouattara spokesman, said that fighting between Ouattara’s and Gbagbo’s fighters had taken place around the presidential palace; the headquarters of the paramilitary gendarmerie, which has been held responsible for attacks on civilians; and Gbagbo’s residence.

In Geneva, the U.N. human rights office urged Ouattara’s camp to restrain its forces after what the agency described as “unconfirmed reports of quite serious human-rights violations.” It also said there had been sporadic reports of pro-Gbagbo troops killing civilians.

At least 1 million people have fled Abidjan and about 500 have been killed during the four months of violence waged by Gbagbo’s security forces, according to the United Nations.