Morocco is keen to strengthen ties with Spain after a rift between the two countries this spring, Moroccan King Mohammed said on Friday, though he added the crisis had shaken mutual trust.
"We are keen today to strengthen (ties) bearing in mind the need for a common understanding of the two nations' interests," he said in a speech.
However, he added that Morocco would not accept "that its best interests be trampled on".
In April, Morocco was angered after Spain admitted a Western Sahara independence leader for medical treatment using Algerian documents, saying it had not been informed. Morocco regards the territory as its own.
Rabat then appeared to relax border controls with Ceuta, a Spanish enclave in northern Morocco, on May 17, leading to an influx of at least 8,000 migrants, most of whom have been returned.
This "unprecedented crisis … shook mutual trust and raised many questions as to their future," said the king, noting that the two countries have discussed bilateral ties since the crisis.
Morocco looks forward to "usher in a new, unprecedented phase in the relations between the two countries, on the basis of trust, transparency, mutual respect and the fulfilment of obligations," he said.
Spain is Morocco's largest trading partner and the two countries have cooperated closely to stem illegal migration.
The king also said that Morocco's relations with France are "solid."
The monarch also defended Morocco's security services and other national institutions against what he called a "full-fledged campaign" to tarnish their image.