Algeria and Morocco should to take action to assure safe passage to 41 Syrian refugees stranded along the border between both countries for weeks, the United Nations refugee agency (UNHCR) said on Tuesday.

The Syrian refugees, including babies and a pregnant woman in need of medical care, have been stuck on the border since April 17, with Morocco and Algeria trading blame in what resulted in a diplomatic row last month.

"There is a sense of urgency in this matter and we call on both governments to take instant and constructive steps to uphold international humanitarian imperatives and evacuate this vulnerable group," the UNHCR said in a statement.

According to Human Rights Watch, the refugees arrived at the border after traveling through Libya and Sudan. The UNHCR said they are in dire circumstances, including exposure to snakes and scorpions in the remote area.

Videos emerged on social media last week showing locals from the border town of Figuig demanding the Moroccan government allow the Syrian refugees in ahead of the holy month of Ramadan, which began last weekend.

Morocco said last month that the Syrians attempted to enter Morocco through Figuig, an area surrounded by mountains, between April 17 and 19. Rabat accused Algeria of forcing them to cross into Morocco.

Algeria rejected the accusations, saying Moroccan officials had tried to dispatch a group of Syrians over the border from Morocco into Algeria.

Some 5,000 Syrians have gone through a migration regulatory process in Morocco, with several hundred receiving refugee status, according to Morocco's ministry of foreign affairs.

The North African neighbours often exchange diplomatic barbs over their 1,500 km land frontier from the Mediterranean Sea to the Sahara Desert. It has been shut since 1994 because of disputes over security.

Morocco and Algeria have had a contentious relationship since independence from France. Border disputes triggered an armed conflict in the 1960s known as the "Sand War".

One of their biggest disputes has been over Western Sahara, a former Spanish colony, most of which Morocco claimed in 1975. Algeria supports and hosts the Western Saharan independence movement Polisario, a stance that angers Morocco.

Source: News agencies