WASHINGTON (AP) — The top United Nations envoy in Somalia is warning that foreign diplomats may have to withdraw from the war-ravaged nation if they continue to be attacked.

U.N. Special Representative Nicholas Kay said attacks that cause significant losses would likely force international officials to leave or, at least, pare down their missions in the Somali capital of Mogadishu.

He spoke Tuesday at the U.S. Institute of Peace in Washington.

Kay said the United Nations is preparing to bolster its funding in programs in Mogadishu after largely retreating following a June 19 attack on its compound by the Somali militant network al-Shabab that killed at least 13 people.

But he acknowledged the risk of doing so and said that would change if the U.N. was hit badly again.