The U.N. special envoy to Somalia moved to Mogadishu on Tuesday for the first time in 17 years, signalling international support for a government fight against Islamist rebels and preparations for elections this year.

High-level officials from the United Nations have been based in neighbouring Kenya since 1995 because of security concerns, although its Political Office for Somalia had a few officers in the Somali capital.

Al Qaeda-linked al Shabaab militants withdrew from most of their bases in Mogadishu last August after sustained pressure from Somali and African Union troops, but violence still grips many parts of the country.

U.N. Special Representative for Somalia, Ambassador Augustine Mahiga, arrived at the airport in Mogadishu, where the U.N. flag was raised. Mahiga was due to meet President Sheikh Sharif Ahmed and African Union force officials.

The United Nations said the move showed its commitment to supporting Somali leaders who adopted a political roadmap in September that is meant to lead to parliamentary and presidential elections in August, ending a series of fragile transitional governments.

It is historic to bring the U.N. back to Somalia. The secretary-general told me I should go and join you to make the roadmap a reality, Mahiga said as he handed a letter from U.N. chief Ban Ki-moon to the Somali president.

Speaking in the presidency later, where Somali men performed a traditional dance, Mahiga called on U.N. agencies and other countries to send their representatives to be based in Somalia.

BALADWAYNE ATTACK

Somalia descended into chaos in 1991 after dictator Siad Barre was ousted. The first internationally backed transitional government was established in 2004 only to lose control to rebels and semi-autonomous administrations.

Al Shabaab, who control many parts of southern and central Somalia, have been able to launch guerrilla-style attacks in the capital despite a Kenyan, Ethiopian and Somali offensive.

On Tuesday, an al Shabaab fighter rammed a minibus loaded with explosives into a government building in Baladwayne, a town in central Somalia about 45 km (28 miles) from Ethiopia.

A minibus carrying explosives entered Baladwayne administration headquarters compound. Government soldiers tried to stop it by firing but all in vain, Hussein Aden, a senior military official, told Reuters by phone.

Aden said there was no immediate report of casualties and the area surrounding the compound had been sealed off.

Aden Abdulle, head of a militia fighting alongside Somali and Ethiopian soldiers against al Shabaab, said the building housed Transitional Federal Government lawmakers and Ethiopian and Somali government soldiers.

Al Shabaab claimed responsibility for the attack.

We carried the car bomb successfully into the Ethiopian and Somali base in Baladwayne this morning. Our brave driver is martyred. There we killed many Ethiopian and Somali troops on a parade, said al Shabaab spokesman Sheikh Abdiasis Abu Musab.

Al Shabaab said in a statement it had killed 33 Ethiopian soldiers and wounded at least 72.

There was no immediate comment from Addis Ababa. Somali government soldier Yusuf Abikar in Baladwayne said no Ethiopian or Somali soldiers had died in the attack, while one Baladwayne resident said there may have been some deaths.

The car bomb destroyed the gate and the front part of the building. At least the Ethiopian and government soldiers who fired at the car bomb from the gate may have died ... it is difficult to know the casualties, shopkeeper Hassan Nur said.

Ethiopian soldiers previously went into Somalia in late 2006 and pushed the Islamist organisation, Islamic Courts Union, out of Mogadishu. The Ethiopian presence helped fuel the rise of al Shabaab and the foreign troops left in early 2009.

Al Shabaab, which wants to impose a harsh interpretation of sharia law on the Horn of Africa nation, has waged a five-year campaign to drive the largely impotent government from power.

(Additional reporting by Ismail Taxta; Writing by Yara Bayoumy and George Obulutsa; Editing by Janet Lawrence)