Spain and four other countries have agreed to take in 51 Africans who have spent a week crammed aboard a small Spanish trawler that rescued them in waters off Malta, the Foreign Ministry said Thursday.

The other countries are Malta, Libya, Italy and Andorra, a tiny principality wedged between Spain and France, the ministry said.

The trawler was expected to be allowed to dock later in the day in Malta. Until now, Malta would not accept the Africans, insisting they were responsibility of Libya, where the group departed from in a small boat.

A ministry official said a Spanish plane was to fly to Malta to take 15 of the destitute travelers to Spain.

Malta's Foreign Minister Michael Frendo said his country could not be expected to take in all the migrants — 42 men, eight women and a baby.

"Europe has finally realized our limits. This has been an example of collaboration and how such a burden can be shared," he said in Malta.

A pregnant woman and another woman and her baby were allowed ashore Tuesday for medical treatment.

Under the deal, Malta has agreed to take in eight, Libya 10, Italy 10 and Andorra eight, the Spanish Foreign Ministry said.

The Africans, most of whom are from Eritrea, spent five days at sea, then another week packed into a space roughly equivalent to that of a small apartment with the 10 crew members of the trawler Francisco y Catalina.

One of the mariners, Bautista Molina, told the newspaper El Pais by cell phone that the crew members have been sleeping just two hours a night, taking turns watching over the Africans in case they need anything.

"We are very happy this is over because no one knows what we have been through — 61 people aboard the ship in stifling heat for so many days," Molina said. "We did what we had to do. We are exhausted but our conscious is clear."