Hundreds of thousands of Afghans living in Pakistan faced the threat of detention and deportation on Wednesday, as a government deadline for them to leave sparked a mass exodus.

The government has given 1.7 million Afghans it says are living illegally in the country until November 1 to leave voluntarily or be forcibly removed.

On Wednesday, thousands joined a snaking queue that stretched for seven kilometers at the busiest border point, where at least 29,000 had crossed back into Afghanistan the day before.