Somalia has asked the UN secretary general’s special envoy to leave the country “as soon as possible” after accusing him of “interfering with the country’s internal affairs”.

A statement from the ministry of foreign affairs on Tuesday declared top UN official Nicholas Haysom persona non grata. The ministry said that Haysom “is not required and cannot work in this country”.

The move comes just days after the envoy sent a letter to the internal security minister, questioning the legality of the arrest of Mukhtar Robow, a former al-Shabaab leader, in Baidoa in early December. The arrest by the UN-supported Somali security forces sparked protests in the south-central town, allegedly resulting in the deaths of 15 civilians and the detention of about 300 people, mostly children according to the envoy’s office.

Haysom asked the government to explain what measures had been taken to prevent civilian casualties and urged that “the matter be thoroughly and promptly investigated and that appropriate action is taken to hold any perpetrators, including commanding officers, accountable”.

In an interview with the BBC Somali service, Somalia’s foreign minister, Ahmed Isse Awad, said that Haysom “has many times done mistakes and released statements without consulting with the government. The last one was the letter he sent to the security minister, in which he addressed him as if the minister was accountable to him.

“We have no problem with the office of the United Nations in Somalia, it is only about one man who perhaps thought he is the ruler of Somalia and he was told that he was not and was asked to leave the country. The rest of the UN agencies are around and they are compliant with the UN protocol and the host country’s regulations.”

Mukhtar Robow, former deputy leader of al-Shabaab. Photograph: AFP Contributor/AFP/Getty Images

Robow was al-Shabaab’s deputy leader but defected from the group in 2017. The US lifted a $5m (£4m) reward for his capture in August last year, and he was welcomed back to the capital by the Mogadishu administration.

However, the government banned him from running for a regional leadership election when he announced his candidacy last October and subsequently arrested him. He was accused of bringing fighters to Baidoa, where he enjoys the support of his clan.

Local elders and residents from the town have come out in support of the UN envoy and his call for accountability. The federal government has been facing strong opposition from federal member states over its involvement in forthcoming regional elections.

The semi-autonomous region of Puntland has banned senior federal government officials from entering the region before this month’s election.

Although opposition leaders condemned the government’s decision to expel Haysom, many ordinary Somalis have praised the move on social media and blamed “foreign intervention” for the country’s longstanding political instability.

Mukhtar Robow talks to the media about his candidacy for a regional presidency in Baidoa, Somalia, before his arrest. Photograph: AP

The UN supports the Somali security forces with training and stipends in the hope that they will take over the country’s security from Amisom, the African Union Mission to Somalia, which is also funded by the international community.

Somalia has been without a stable government since 1991. Haysom, a lawyer from South Africa, was appointed by the secretary general last September to lead the UN mission in Somalia and help with the country’s political and humanitarian situation.

According to the UN Office for the Co-ordination of Humanitarian Affairs, more than 4 million Somalis are estimated to require assistance in 2019.

At a press briefing on Wednesday, Farhan Haq, deputy spokesman for the UN secretary general, said that he could not officially confirm Haysom’s expulsion. “We’re trying to get the various details corroborated, and we’re going to see, based on that, what further steps are needed,” he told journalists.