MOGADISHU, Somalia  From the gates of Villa Somalia, the hilltop presidential palace, this ruin of a city almost looks peaceful.

After nearly two decades of civil war, there is very little pollution, since just about all of Somalia’s industry has been razed. A clean breeze lifts off the ocean and stirs the bougainvillea. Few cars remain in the city and relatively few people, because hundreds of thousands have recently fled. It is surreally quiet, except for the occasional crack of a high-powered rifle.

President Sheik Sharif Sheik Ahmed sits behind his desk in a pinstriped suit, prayer hat, designer glasses and a chunky, expensive-looking watch. He is ringed by enemies and guarded around the clock by Ugandan soldiers who literally camp outside his door and, for the rare occasions he leaves the palace, drive him to the airport in an armored personnel carrier. The few glimpses he gets of Mogadishu’s deserted streets are through two-inch-thick bulletproof glass.

“This government faced obstacles that were unparalleled,” said Sheik Sharif, a former high school teacher, who became president in February. “We had to deal with international terrorist groups creating havoc elsewhere. Their plan was to topple the government soon after it arrived. The government proved it could last.”