(CNN) A ship carrying more than 300 migrants rescued off the coast of Libya last week arrived in Spain on Friday.

The rescue vessel, operated by the Spanish charity Proactiva Open Arms, had earlier been denied entry by Italy and Malta, the charity said.

The charity said the migrants -- mainly from Somalia, Nigeria and Mali -- were in three separate boats "in danger of shipwreck" when they were found on December 21.

The ship docked at a port near Algeciras in southern Spain on Friday morning.

Buenos días, el #OpenArms ya en la bahía se dirige al punto de atraque, del único puerto seguro disponible en el Mediterráneo. Misión cumplida. pic.twitter.com/L6nw1FXlB2 — Oscar Camps (@campsoscar) December 28, 2018

"Open Arms is already in the Bay of Gibraltar and is steering towards the only port available to it in the Mediterranean. Mission accomplished," the charity's founder, Oscar Camps, tweeted Friday.

Read More