ISLAMABAD—Afghanistan’s neighbors have closed their land borders to people trying to flee its new Taliban rulers, trapping tens of thousands of people who are eligible to resettle in the U.S. and other countries but were unable to enter the airport in Kabul before the international airlift ended.

None of Afghanistan’s airports are currently open, though Qatar has begun efforts to restore flight operations in Kabul. This means that the few at-risk Afghans who managed to leave overland were trafficked out or used fake documents.

The U.S. estimates that the majority of Afghan interpreters and others who had applied for visas to flee the country were left behind after August’s international evacuation effort transported more than 120,000 people from Kabul, a senior State Department official said.

In Kabul on Thursday, the Taliban started preparing for the official inauguration of their government that is expected in coming days. Thousands of white flags of the Taliban’s Islamic Emirate are being manufactured, according to footage on social media. In the Panjshir valley north of Kabul, the only part of the country not under Taliban control, fighting continued between the Taliban and resistance militias.

A helicopter displaying a Taliban flag flew in Kandahar on Wednesday.

Photo: javed tanveer/Agence France-Presse/Getty Images

In previous stages of Afghanistan’s more than four decades of wars, starting with the 1979 Soviet invasion, Pakistan took in millions of refugees, many of whom never left. Now, it isn’t willing to accept any more. The other major sanctuary, Iran, isn’t letting them enter either, and neither are Central Asian states.

More than half a million Afghans were displaced from their homes this year in fighting between the Taliban and the former Afghan government, according to the United Nations. The Taliban completed their military takeover by entering Kabul on Aug. 15, after a lightning conquest of the rest of the country.

Related Video

The Taliban seized control of Afghanistan faster than intelligence officials expected. The Wall Street Journal Interactive Edition

The U.N. called this week for the neighboring states to open their borders, and for countries outside the region to provide more resettlement places for Afghans. That is a tough sell, particularly in Europe, where anti-immigrant sentiment has become a major political issue in the wake of the 2015 Syrian refugee influx.

European interior ministers meeting this week said that they didn’t want to see large-scale illegal migration and that they would bolster support to Afghanistan’s neighbors “to ensure that those in need receive adequate protection primarily in the region.” However, the European Union and some member states said they were open to welcoming some at-risk Afghans as part of an international resettlement program.

Afghan refugees in a reception center in Avezzano, Italy, on Wednesday.

Photo: massimo percossi/Shutterstock

The U.S. State Department said that those wanting to apply for refugee status should make their way out of Afghanistan first, adding, “We recognize that it may be difficult for Afghans to obtain a visa to a third country or find a way to enter a third country.” The “special immigrant visas” for interpreters and others who worked closely with the U.S. is a separate program, and its application processes are still being worked out following the closure of the embassy in Kabul.

The U.K. has said it would offer asylum to up to 20,000 Afghans over the next five years, in addition to those airlifted out last month.

“I had my legal life in Kabul for the last 20 years. Then I was forced to cross the border illegally,” said a man who worked for contractors to the U.S. government, the U.N. and directly for the Afghan government, making him a likely target for the Taliban. “I don’t know what will come next for me.”

The man, who belongs to the Hazara ethnic and religious minority that was persecuted in the Taliban’s last period in power in the 1990s, hid in Kabul for a week after the group entered the capital. On finding the mayhem at Kabul airport too dangerous, and getting no response from Western embassies, including the U.S. and Canadian missions, he took a bus south to Kandahar with his wife and three children, where he found a people smuggler who got the family into Pakistan.

The Taliban say they will allow Afghans with valid passports and visas to travel out of the country. So far, the country’s passport offices remain closed. The embassies of all Western nations and India have shut down and their diplomats have left the country.

The country’s economic meltdown following the Taliban takeover, with food, fuel and cash running out, could soon push even larger numbers of Afghans to try to escape, aid workers say.

“When the airlift and the media frenzy are over, the overwhelming majority of Afghans, some 39 million, will remain inside Afghanistan. They need us,” Filippo Grandi, the U.N. High Commissioner for Refugees, said this week. “They must be able to exercise their right to seek international protection, and borders must be kept open for them for this purpose.”

The UNHCR says there hasn’t been a significant increase in the numbers crossing the Pakistani or Iranian borders from Afghanistan over the past couple of weeks. It warns that Iran and Pakistan, together home to almost 90% of past registered Afghan refugees, will struggle financially to cope with more.

Pakistan already hosts 1.4 million registered Afghan refugees, though believes the true number to be around 3 million.

The country helped evacuate more than 9,000 Afghans and foreigners from more than 20 nations in the second half of August, mostly by air, but almost all of them simply transited through. Pakistan says it is working to help bring stability to Afghanistan, so that a refugee exodus can be forestalled.

“We are the country that has the greatest number of Afghan refugees right now. It is very clear that we would not like to have more,” said Asim Ahmad, spokesman for Pakistan’s Ministry of Foreign Affairs.

The closest crossing point to Pakistan from the Afghan capital, going east to Torkham, is closed to Afghans, other than in exceptional cases such as medical emergencies. The other main crossing point, south from Kabul at Chaman, is open but only to those who have documents to show they live close to the border and therefore can benefit from longstanding special arrangements for border areas.

Trucks carrying trade goods waited to cross into Afghanistan from Pakistan at the Chaman border point on Thursday.

Photo: stringer/Shutterstock

Locals estimate that several thousand Afghans have been smuggled across Chaman over the last couple of weeks, paying up to $90 a person. Afghans are also paying hundreds of dollars for taxi rides within Afghanistan to reach the border crossing, and from the border to the nearest major Pakistani city, Quetta, with fares hiked up to 10 times the normal.

Afghans who made the journey said that entering Pakistan via Chaman was an easier option than going to other countries. Nevertheless, some queued for two days at the border amid a crush of people and were still turned away, even after paying traffickers.

Pakistan says that no new refugees have arrived in recent weeks. The UNHCR says it has been approached by some Afghans in Pakistan for asylum, but couldn’t give numbers. Those unofficially in Pakistan say they want help from the U.S. and other nations to move on.

Entering Iran is an even tougher option, despite an announcement from Tehran that it would set up camps on its side of the border. Only those with visas or other travel documents can get across, according to the UNHCR.

A 23-year-old engineering student at Kabul University said he and friends paid a smuggler $200 each to cross into Iran from the adjacent Afghan province of Nimroz. They were taken to the border, where hundreds were crossing. They ran across with Iranian guards shooting in the air and demanding they stop, but they kept going, meeting the smuggler again on the other side. For the next 24 hours, they had no food or drink. It took six days to arrive in Tehran, where they have to be on the constant lookout for authorities searching for illegal arrivals.

“I was a good student with nice dreams at Kabul University. Now, I am an Afghan laborer in Tehran and can’t go out, can’t study, can’t be counted as a real human being,” he said. “I am heartbroken.”

Write to Saeed Shah at saeed.shah@wsj.com