The Syrians have been stranded in the area "exposed to the elements and the serious threat of scorpions and snakes" since April 17.
"Prompt action by both governments is needed in facilitating the immediate and safe passage of the forty-one vulnerable Syrian refugees," said the UNHCR.
"We urge Algeria and Morocco to work with us on ending this dangerous and untenable situation for these stranded desperate Syrian refugees," it said in a statement.
The group includes "children, babies and women -- including at least one pregnant woman reportedly in need of urgent Caesarean section", the statement said.
The Syrians have been stranded in the area "exposed to the elements and the serious threat of scorpions and snakes" since April 17, it added.
At the time, Morocco accused its neighbour of expelling the refugees to "sow trouble" and "generate an uncontrollable flow of migrants".
Algeria "categorically" rejected the allegations as false.
It sparked a diplomatic spat, with each country summoning the other's ambassador.
The land zone between the two countries has been closed since 1994. The North African rivals have very difficult relations, especially over the question of Western Sahara.
The UNHCR said it understood neither country considered the Syrians to be in their territory, but called "for action to bring the group to safety on humanitarian grounds".
The UN agency was "ready to offer its 'good offices' to coordinate this life-saving evacuation," it said.
Since Syria's war started in 2011, millions of people have been forced to flee their homes.