MOGADISHU, Somalia - At the beginning of the year, armed Islamic extremists held sway over most of Mogadishu. Today, this war-scarred capital is secure enough to host the first visit by the U.N. secretary-general in nearly two decades.

Ban Ki-moon announced during a surprise visit to Mogadishu on Friday that the United Nations will reopen its political offices in this seaside capital, a city heavily scarred by war.

The announcement underscored the security progress made by African Union troops in the fight against al-Shabab militants, but also of the need for the U.N. to more closely monitor the Somali government, which is funded by foreign donors.

Ban, who was wearing a dark blue bulletproof vest when he landed, said Somalia was more than just famine and corruption. "I believe we are now at a critical juncture, a moment of fresh opportunities for the future of Somalia people . . . to bring a new measure of stability and possibilities to people's lives," he told a news conference the presidential palace.

Somali President Sheik Sharif Sheik Ahmed called the trip historic and said it proved that progress was being made.

Ban said that the U.N. Political Office for Somalia would relocate to Mogadishu from Nairobi, Kenya, in January. He also welcomed the decision by Kenya's parliament this week to contribute soldiers to the African Union force in Somalia, which is now composed mostly of Ugandan and Burundian troops.

Kenya's military spokesman said Friday that the country's contribution to the African Union force - approved by Kenya's parliament Wednesday - would take overall numbers of peacekeepers in Somalia above the 12,000 allowed by a U.N. Security Council mandate.

Maj. Emmanuel Chirchir said the addition of Kenyan troops to the AU force, currently 9,000 strong, still requires Security Council approval.

Ban told Somalia's political leaders that they must make faster progress on a four-point plan to improve security, governance, reconciliation, and create a constitution. The road map must be implemented by next August or the government risks losing international aid.

One reason the U.N. political office is opening in Mogadishu is to enable the U.N. to keep closer tabs on Somalia's leaders and ensure they are making more progress toward the four goals, a U.N. official said. He spoke on condition that he not be identified because of the sensitive nature of the issue.

After meeting with Mogadishu's leaders, Ban spoke at a news conference in which he stressed the importance of seizing the moment. "We have a very limited window of opportunity," he said. "Now is the time to advance on the Constitution and parliamentary reform."