The Government has offered protection to five unaccompanied child migrants who have been seeking refuge in Malta after being rescued from the Mediterranean.

Minister for Justice Charlie Flanagan said the children would be taken in from Malta as a gesture of solidarity and humanitarian assistance.

He was speaking after the conclusion of discussions between Irish officials, the Maltese authorities and the European Commission.

The minister said these children had been rescued from the Mediterranean Sea in humanitarian search and rescue missions and they had been through a terrible ordeal. 

The children will be welcomed to Ireland under the Irish Refugee Protection Programme.

It came as nearly 50 migrants stranded at sea for weeks aboard two rescue ships arrived in Malta after it reached a deal with other EU member states, ending a standoff that rights groups branded "shameful".

"An ad hoc agreement has been reached," Malta Prime Minister Joseph Muscat told journalists.

He said that the deal also included a decision on the fate of 249 rescued migrants already on the island.

The 49 migrants, including a baby and several children, were rescued by two boats on 22 and 29 December while attempting the dangerous Mediterranean crossing from North Africa to Europe.

But with no country allowing them to dock, they were left stranded off the coast of Malta.

They suffered sea sickness and dehydration, with some briefly refusing food and an onboard doctor warning of psychological stress.

There were ecstatic cheers on board the Sea-Watch 3 when a crew member told them "we have a safe port, it's over", according to a video tweeted by the German NGO Sea Watch International.

The migrants arrived in Malta this afternoon after being transferred from the Sea-Watch 3 and Dutch-flagged Albrecht Penck ships to Maltese coastguard vessels.

Mr Muscat said that of the total of 298 migrants, 176 would be sent to Germany, France, Portugal, Ireland, Romania, Luxembourg, the Netherlands and Italy.

Another 78 will be allowed to stay in Malta, and 44 Bangladeshi migrants will be sent back to their country.

Those pulled to safety by the two rescue ships had been unable to disembark because of a diplomatic deadlock among EU member states, despite an appeal by Pope Francis on Sunday.

"The past weeks have not been Europe's finest hour ... If human values and solidarity are not upheld, then it is not Europe," said EU migration commissioner Dimitris Avramopoulos.

Amnesty International's Southern Europe researcher Elisa De Pieri said the time taken to reach a decision on the migrants' fate was "shameful".

"The dangerous, unseemly spectacle of politicians bickering whilst women, men and children are stranded in a sea of cruel indifference, must not be repeated," she said.

Additional reporting Jackie Fox, Joe Little, AFP