The foreign affairs ministry said in a statement late on Tuesday that Nicholas Haysom, the Special Representative of the UN Secretary-General for Somalia, "is not required and cannot work in this country", effectively declaring the official persona non grata.
"The decision comes after he openly breached the appropriate conduct of the UN office in Somalia," the statement read.
There was no immediate comment from the UN mission in the volatile, impoverished country in the Horn of Africa.
The United Nations is a major backer of Somalia, which is trying to claw its way out of the embers of the civil war that engulfed it in 1991, when clan warlords overthrew a dictator and then turned on each other.
The government's move comes after Haysom sent a letter dated Dec. 30 to the interior security minister expressing concern over "the alleged involvement of UN-supported Somali security forces in the arrest of Mukhtar Robow on 13 December, the deaths of 15 civilians...on 13, 14, and 15 December...and the arrest of approximately 300 people involved in the demonstrations on 13, 14, and 15 December".
Robow, the individual referred to in the letter, is a former Islamist al Shabaab militant whose bid to become a regional leader in the country in an election last month was blocked.
The Internal Security Ministry said that Robow was arrested on suspicion that he had brought militants and weapons back to the southern city of Baidoa, the capital of South West region where he is running for president.
His arrest sparked clashes between militiamen loyal to Robow and Somali forces. Ethiopian security forces, who are part of an African Union peacekeeping force in Somalia, were also involved in the violence.
Al Shabaab has sought for over a decade to topple the central government and implement its strict version of Islamic law. It was driven out of the capital in 2011 but maintains a foothold in some regions including South West.
Robow, however, publicly renounced violence and recognized federal authority in 2017.
In the letter, Haysom asked the minister to explain the legal basis for Robow's arrest. He also asked what action had been taken to investigate the circumstances of the deaths during the demonstrations in Baidoa following Robow's arrest. He said that the UN understood that most of those detained were children.The UN letter also contained an annexed joint letter from the European Union, Germany and Britain announcing the suspension of their support to the police in South West state due to their conduct during last month's election. Haysom also detailed the UN support to the Somali police force and the South West regional police which includes the payment of stipends to the police.