VALENCIA, Spain -- Ships in the Aquarius aid convoy docked Sunday at the Spanish port of Valencia, ending a weeklong ordeal for hundreds of people who were rescued from the perilous Mediterranean only to become the latest pawn in Europe's battle over immigration.

The Italian coast guard vessel Dattilo was the first of the three boats bearing the 630 migrants to touch land just before 7 a.m. Sunday. The 270 migrants on board soon began to disembark after medical staff had made a preliminary inspection.

The rescue ship Aquarius came in four hours later with another 106 migrants. Aid workers awaiting their arrival clapped and cheered as the first migrants walked down the gangway. Another Italian navy ship, the Orione, came in shortly after 1 p.m.

The Aquarius, operated by the aid groups SOS Mediterranee Sea and Doctors Without Borders, was stuck off the coast of Sicily on June 9 when Italy refused it permission to dock and demanded that Malta do so. Malta also refused.

Get Breaking News Delivered to Your Inbox

"The weather was very bad unfortunately, and the sea was rough," Sophie Beau of SOS Mediterranee Sea told BBC News. "So people are in a bad state ... and they are really relieved to come on safe land at the moment."

Migrants onboard the French NGO SOS Mediterranee Aquarius ship Orione as it arrives at the eastern port of Valencia, Spain, Sunday, June 17, 2018. Alberto Saiz / AP

After days of bickering and food and water running low on the ship, Spain stepped in and granted the rescue boat entry. The 930-mile journey across the Mediterranean from Sicily to Valencia took nearly a week.

David Noguera, the head of Doctors Without Borders in Spain, said he was glad that Spain allowed the migrants in but he's worried that more European nations will close their ports to those rescued at sea in the future.

"I have mixed feelings," he told The Associated Press on Sunday as the first boat arrived. "I am happy that the journey (for the Aquarius migrants) is over -- a journey that was too long -- and I am worried for the situation in the Mediterranean and the closing of European ports."

The migrants were met by emergency workers, health officials, Red Cross volunteers and psychologists at the city's marina. Each were assigned to a translator and authorities worked to determine their identities before they were sent to welcome centers. The first migrant was a 29-year-old man from South Sudan.

Valencia emergency official Jorge Suarez said some of the migrants were in a state of shock.

"They are very shaken," Suarez said. "Put yourself in their position, you get off a ship and the first people who greet you are wearing masks."

The route the Aquarius took before reaching Spain. BBC News

He said an examination of the 130 migrants from the Dattilo did not reveal any serious health problems but many passengers showed signs of exposure to high temperatures at sea.

Spanish authorities are examining the migrants on a case-by-case basis to see who may qualify for asylum.

Due to their ordeal, the migrants from the Aquarius have been granted special authorization to remain in Spain for 45 days before they must begin resolving their legal situation.

"We have to strike a balance between our sensibilities and humanity and our respect for the law," said Spain's migration minister, Magdalena Valerio.

"These people could not be left adrift in the Mediterranean, where they would face death," she told Spanish radio Cope. "(The EU) must recognize that it needs an immigration policy that these times require."

The migrants reportedly include 123 unaccompanied minors, 11 children and as many as seven pregnant women. After Spain invited the Aquarius to land, Italy sent the Dattilo and Orione to help transport the migrants.

The refusal by Italy and Malta to allow the Aquarius to dock has reignited a continent-wide battle over how to handle immigration.

Under the EU's asylum laws -- currently the subject of a major political dispute and under revision -- migrants must apply for asylum in the country where they first enter Europe. In practice, the policy has placed a heavy burden on Italy and Greece, where hundreds of thousands of asylum-seekers have arrived in recent years.

Spain's new Socialist government has taken up the cause of the migrants to demonstrate its commitment to protecting human rights.

But overall, the European Union's 28 members have not agreed in the least how to handle the influx of refugees and migrants to Europe. The issue has put strong domestic pressure on German Chancellor Angela Merkel, created a spat between France and Italy, and prompted eastern nations like Hungary and Poland to refuse to take in any migrants.

Immigration will be a top issue at the EU leaders' June 28-29 summit. In addition, a new populist government in Italy -- one whose interior minister has vowed to deport tens of thousands of migrants as soon as he can -- will make any compromises on EU migration policy even more difficult.

The warmer weather has caused a spike in migrants taking off from North Africa for Europe. Spain's maritime rescue service pulled 986 people from 69 small smuggling boats near the Strait of Gibraltar between Friday and Saturday, and also recovered four bodies.

At least 792 migrants have died crossing the Mediterranean so far this year, according to the United Nations. Through the first five months of 2018, some 35,455 migrants reached European shores.