By Alastair Leithead
BBC News, Kabul
Thousands of Pakistanis have fled into Afghanistan with the security situation deteriorating in Pakistan's tribal regions over the past week.
Hundreds of families, comprising some 6,000 mainly women and children, have been crossing the border.
The UN refugee agency says clashes between Pakistan's Shia and Sunni groups have forced people to flee.
It is the first time so many people have crossed this way as for years it was Afghans fleeing fighting.
The refugees have been crossing the border between Pakistan's tribal areas and south-eastern Afghan provinces.
The UN refugee agency (UNHCR) says historic clashes between Shias and Sunnis in the villages in Kurram, North West Frontier Province, have escalated in the past couple of weeks.
This and the unstable situation in that part of Pakistan have led to the movement of so many people, the UNHCR says.
"It's the first time that we see this in very large numbers which shows that security in those areas has seriously deteriorated and it's probably become out of control," said Salvatore Lombardo, a UNHCR representative in Kabul.
He said many of the people had been given shelter in Afghanistan by villagers who live by the Pashtun Valley tribal code of hospitality, and tents were being handed out to help provide shelter as winter was intensifying along the border.
Over the past three decades millions of Afghans fled the violence in their country during the Soviet occupation, the civil war and then in the fighting that saw the Taleban take control of Afghanistan.
With the rise of the Pakistani Taleban and militant Islamic groups along the Pakistan side of the border, the UN says it now appears that parts of Afghanistan are safer for families.
It is hoped discussions within the tribal groups can resolve the situation and allow the people to return home.