ALGIERS (Reuters) - Algeria has agreed to allow 41 Syrian refugees stranded on its frontier with Morocco to stay in the country as a humanitarian gesture, the foreign ministry said.

Earlier this week the United Nations refugee agency UNHCR urged Morocco and Algeria to allow the group safe passage after they had been trapped for weeks in a dispute between the North African neighbors.

In a statement on APS state news agency, Algeria’s foreign ministry said the refugees, including children and a pregnant woman, would be allowed to stay after being blocked in the border town of Figuig.

Morocco and Algeria blamed each other for the situation.

The two countries often exchange diplomatic barbs over their 1,500-km (970-mile) frontier, which stretches from the Mediterranean Sea to the Sahara Desert. It has been shut since 1994 because of disputes over security.

Morocco said the Syrians attempted to enter Morocco through Figuig between April 17 and 19. It accused Algeria of forcing them to cross into Morocco. Algeria rejected the accusation, saying Moroccan officials had tried to send the group into Algeria.