Alfredo Perez Rubalcaba, Spain's interior minister, has sought to defuse a dispute with Morocco over immigration and the alleged abuse of Moroccans by Spanish police, during a visit to Rabat.
Morocco has issued five statements in recent weeks claiming police in Mellila, a Spanish enclave in north Africa, beat up visiting Moroccans, as well as accusing Madrid of abandoning African migrants in the Mediterranean Sea.
Following talks in the capital on Monday with Taib Cherkaoui, his Moroccan counterpart, Rubalcaba said the incidents had served to bolster police co-operation between the countries.
"There was a series of incidents that are now in the past. We have sat down and agreed to a number of things to improve police co-operation," he said.
"We are happy to work together because we share the same risks and problems - illegal immigration, drugs, and terrorism."
On Wednesday, activists in Morocco who have twice stopped food shipments into Mellila over the alleged police abuse, agreed to suspend their demonstrations until September.
The deal to end the action during the Islamic month of Ramadan brought a temporary end to the on-and-off commercial blockade of Mellila, a city of 70,000 people, which Morocco calls "occupied" territory.
In another incident that has caused tension between the two countries, Morocco alleged earlier this month that Spanish police had abandoned eight sick sub-Saharan migrants off the Moroccan coast after intercepting them trying to enter Spain.
Rubalcaba said on Monday that he had formally agreed to meet at least once a year with his counterpart to assure stable relations between Morocco and Spain.
He said police from both countries would meet quarterly to try and work closer together within Mellila and Ceuta, another disputed enclave.
Rubalcaba said both countries will establish two police offices in Tanger and Algeciras by next summer where both Spanish and Moroccan police will work side by side.
Moroccan officials said privately on Monday that Rabat was upset about what they said was Spain's expansion of spying activity in the north of the country and a lack of enthusiasm from Madrid towards Morocco's newly-appointed ambassador to Spain.
They also cited the flying of Spanish military helicopters over northern coastal areas during visits there in June and July by Morocco's King Mohammed VI.
Rubalcaba held talks with the king earlier on Monday.