UN Secretary-General Ban Ki-moon regrets a "misunderstanding" over his use of the word "occupation" to describe Morocco's annexation of Western Sahara, which led to Morocco expelling dozens of US staff, his spokesman has said.

Earlier this month Ban used the word "occupation" to describe the annexation in 1975, when Morocco took over the arid territory along the Atlantic Ocean from colonial power Spain.

"His use of the word was not planned, nor was it deliberate. It was a spontaneous, personal reaction. We regret the misunderstandings and consequences that this personal expression of solicitude provoked," UN spokesman Stephane Dujarric told reporters on Monday.

The controversy over Ban's comments is Morocco's worst dispute with the UN since 1991, when the UN brokered a ceasefire to end a war over Western Sahara and established a peacekeeping mission, known as MINURSO.

READ MORE: Morocco's king rules out compromise over Western Sahara

Ban said the word during a visit to refugee camps in southern Algeria for the Sahrawi people, who contend that Western Sahara belongs to them.

Morocco then ordered the UN to pull out dozens of civilian staffers and close a military liaison office for the MINURSO peacekeeping mission.

It said its decision was irreversible, but that the government was committed to military cooperation to guarantee a ceasefire.

"Nothing [Ban] said or did in the course of that trip was meant to offend or express hostility toward the Kingdom of Morocco, which is a valued member of the United Nations," Dujarric said.

Rabat has accused Ban of dropping the UN's neutral stance on the Western Sahara dispute.

Conflict in Moroccan Sahara: Myths and realities

"The position of the United Nations has not changed," Dujarric said. "He has not and will not take sides on the issue of Western Sahara."

UN officials had repeatedly urged the UN Security Council to publicly voice its support for Ban and MINURSO, which the 15-nation body did late last Thursday in New York.

However, the council did not explicitly order Morocco to reverse its decisions or address Ban's use of the word "occupation".