Flanked by a guard wearing a white UN helmet, Ban was welcomed by Prime Minister Abdiweli Mohamed Ali on the first visit by a UN chief to Mogadishu, often described as the world's most dangerous city, in alsmost two decades.
Ban told reporters after meeting Somalia's transitional leadership: "We call on the opposition armed group Al-Shabaab to stop violence and participate in the peace process in the country."
After making a brief visit to the African Union mission at its airport base, AU forces escorted him through the bombed-out city to the presidential palace.
"Security is tightened and everything is under control," said a government security official.
Ban said his visit was the first to Mogadishu since 1993, when the world body still had a large Somalia peacekeeping force, whose deployment was considered a debacle and left a lasting trauma among Western military planners.
Somali President Sheik Sharif Sheik Ahmed, who had earlier been reported to be out of the country, said the visit "encourages peace and development" and "demonstrates how security has improved in Mogadishu."
The city has nonetheless seen an increase in grenade and roadside bomb attacks since Shabaab abandoned fixed positions there in August and switched to guerrilla tactics against the Western-backed government.