MOGADISHU, Somalia — The Somali government is preparing a major offensive to take back this capital block by crumbling block, and it takes just a listen to the low growl of a small surveillance plane circling in the night sky overhead to know who is surreptitiously backing that effort.

“It’s the Americans,” said Gen. Mohamed Gelle Kahiye, the new chief of Somalia’s military, who said he recently shared plans about coming military operations with American advisers. “They’re helping us.”

That American assistance could be crucial to the effort by Somalia’s government to finally reassert its control over the capital and bring a semblance of order to a country that has been steeped in anarchy for two decades. For the Americans, it is part of a counterterrorism strategy to deny a haven to Al Qaeda, which has found sanctuary for years in Somalia’s chaos and has helped turn this country into a magnet for jihadists from around the world.

The United States is increasingly concerned about the link between Somalia and Yemen, a growing extremist hot spot, with fighters going back and forth across the Red Sea in what one Somali watcher described as an “Al Qaeda exchange program.”