Somali troops and their Ethiopian allies have been trying to wipe out the insurgents since late March, with the unrelenting rain of mortar shells and artillery taking the highest toll on civilians. Rights groups say the fighting killed more than 1,000 people and sent up to 400,000 fleeing for safety.

Machine gun and artillery fire could still be heard in the south of Mogadishu, a wrecked coastal city of 2 million people. Fifty-eight people, mainly civilians, were killed in fighting early Thursday as the Ethiopian and government forces drove insurgents out of their stronghold in the north of the city, according to Somalia's Elman Human Rights Organization.

In the past nine days alone, the death toll was more than 400.

"We have won the fighting against the insurgents," Prime Minister Ali Mohamed Gedi told The Associated Press, saying small, mopping-up operations were still under way and that more than 100 insurgents had surrendered to the government.

"The worst of the fighting in the city is now over," he said.

Western diplomats, who spoke on condition of anonymity for fear of damaging relations with Somalia's government, said the insurgents had suffered large numbers of casualties and were running low on ammunition, but were not yet defeated.

"People can now return to their homes," Gedi said. "The rest of the fighting will be over soon. We have captured the stronghold of the terrorists. We will capture any terrorists who have escaped."

But Somalia is facing a dire humanitarian crisis after the fighting leveled homes and sent hundreds of thousands of civilians into squalid camps or seeking shelter along roadsides.

The United Nations' top humanitarian official said Thursday that more people have been displaced in Somalia than anywhere else in the world this year. And, he said, international aid groups only have access to a fraction of them.

"The situation is indeed extremely worrying," said John Holmes, the U.N. undersecretary-general for humanitarian affairs. While U.N. agencies and other relief groups are trying to provide aid, they can only reach about 60,000 of the homeless at the moment because of fighting in and around the capital of Mogadishu.

The insurgents are linked to the Council of Islamic Courts, which was driven from power in December by Somali and Ethiopian soldiers, accompanied by U.S. special forces. The U.S. has accused the courts of having ties to al-Qaida.

The militants reject any secular government, and have sworn to launch an Iraq-style insurgency.

Gedi told the AP that he was confident the group would not re-emerge because the government and allied forces were seizing the insurgents.

"They are not getting away, we are capturing them, we are bringing them to justice," he said. "That is the difference compared to what happened in December."

Earlier Thursday, Ethiopian tanks and artillery had pounded the northern stronghold, as cease-fire talks foundered and rumors spread that a top Islamic rebel had arrived in the capital. But most of the heavy guns fell silent midmorning.

Meanwhile, bodyguards linked to a top Islamic extremist, Sheik Hassan Dahir Aweys, arrived in Mogadishu on Wednesday, sparking rumors that Aweys and Shabab leaders were leading the fighting against the Somali and Ethiopian troops.

Most of the leadership of the Council of Islamic Courts has either fled the country, or been in hiding since Ethiopia intervened in December to prop up the government.

The Shabab, which the United States accuses of having ties to al-Qaida, have taken credit for a string of suicide bombings against Ethiopian troops.

Somalia has not had an effective national government since 1991, when warlords overthrew dictator Mohamed Siad Barre and then turned on one another, throwing the country into anarchy. The current administration was formed in 2004 but has struggled to extend its control over the country.

More than 5.8 million people voted for Nicholas Maduro at the presidential election in Venezuela. This is more than a quarter of registered voters. Why did those people vote for the man, who, as Western media write, took Venezuela to the brink of collapse?