King Juan Carlos of Spain has called for a fair final settlement of the Western Sahara dispute, in a speech to the Moroccan parliament in Rabat.
Royal summit: A warm reception for King Juan Carlos (left)
He said Spain wanted to see a "consensual, just and final" settlement for the former Spanish colony.
The Polisario Front has been fighting for independence since the territory was annexed by Morocco in 1975.
Since the Casablanca and Madrid bombings Morocco and Spain have stepped up their anti-terror co-operation.
The king said the anti-terror fight must "not be conducted in a blind or indiscriminate manner," but must conform to existing legal norms, the Spanish news agency Efe reported.
In a letter to King Juan Carlos, quoted by the French news agency AFP, the Polisario leader, Mohamed Abdelaziz, said Spain and Morocco shared responsibility for the "tragedy" afflicting the Sahrawi people.
He urged Spain to play a positive role in promoting peace and justice in Arab North Africa.
Successive United Nations attempts to negotiate a settlement between Morocco and Polisario have remained stalled.
Moroccan-Spanish relations have thawed since a Socialist government was elected in Spain last March, to replace the previous conservative administration.
A low point in Spanish-Moroccan relations was a dispute two and half years ago when Spanish troops expelled a group of Moroccan soldiers from the disputed Mediterranean island Perjil.
But the king and Queen Sofia were welcomed to the old royal city of Marrakech by thousands of people waving flags when they arrived on Monday.
The two kings made it clear they wanted to draw a line under the crisis period.
"Our two countries, despite the vicissitudes of politics, have been able to maintain constructive dialogue and mutual trust," King Mohammed told his guest in Spanish.
"What unites us is much stronger than what has been able to divide us," King Juan Carlos replied.
Last year Spain and Morocco reinforced their co-operation by signing an agreement on combating terrorism, drugs and human trafficking.
Eleven of the 18 people charged with carrying out the 11 March Madrid train bombings are Moroccans.
Investigators reportedly linked one of the key suspects, Hasan al-Haski, to the bombings carried out in the Moroccan city of Casablanca in 2003.