The Taliban were in control of Afghanistan's main crossing with Tajikistan on Wednesday following a blistering onslaught across the country's north, as President Ashraf Ghani prepared to visit Washington.

The militants have swallowed up a dizzying number of rural districts in recent weeks, stirring fears that Afghan security forces will buckle once US and international troops wind up their withdrawal from the country.

Tuesday's capture of the border hub of Shir Khan Bandar -- along the key trade route to Central Asia -- came as the Taliban encircled nearby Kunduz city, putting it on the verge of becoming the first provincial capital to fall.

"There are many, many displaced people who fled the districts to come here, but there is no electricity, no water and the fighting has reached the gates of the city," Gulbuddin, a 25 year-old resident of Kunduz, told AFP.

"The markets are mostly closed, and there is serious shortage of food items and other basic stuff in the city," added Mustafa, another local who gave only his first name out of security concerns.

Afghan government forces have vowed to retake lost territory, while several informal militias in the north have also begun mobilising.

But Kunduz provincial council member Amruddin Wali said it appeared there were no plans at the moment for a government counteroffensive at the border.

Tajikistan's national security committee confirmed Tuesday that more than 100 Afghan servicemen had crossed the border to escape the Taliban onslaught.

"We have reports from our local staff that the Taliban have confiscated all the goods and commodities in the port, and they have destroyed the customs office," said Massoud Wahdat, a spokesman for the Kunduz chamber of commerce and industries.

A Taliban spokesperson denied their forces had ransacked the facilities and sought to reassure the traders that business would continue at the Tajik border crossing despite the fighting.

Map of Afghanistan locating Shir Khan Bandar, the main border crossing with Tajikistan.
Map of Afghanistan locating Shir Khan Bandar, the main border crossing with Tajikistan. AFP / STAFF

"All commercial import and export will function as normal and administrative work of traders will continue uninterrupted," said a statement released by the Taliban.

The surge in violence comes as President Ghani is set to land in Washington later this week, where he will meet with his counterpart Joe Biden in the White House.

The speed and breath of the Taliban's offensive has stirred fears that Afghan security forces may crumble in the absence of vital US airpower and logistical support.

Since early May, the Taliban have launched several major offensives targeting government forces and say they have seized over 80 of the country's 421 districts, although many of their claims are disputed by the government and difficult to independently verify.

The Pentagon said on Monday that it would complete its full withdrawal by September 11, but the pace of the pullout could be slowed given the Taliban's gains.

Over the weekend, Ghani replaced two top ministers charged with managing the country's faltering security.

The embattled leader appears to be increasingly isolated in Kabul, while infighting within the government is rife and peace talks with the Taliban in Qatar deadlocked.

Biden has ordered the departure of all US forces from Afghanistan by this year's 20th anniversary of the September 11 attacks that triggered the invasion.

In moving to end America's longest war, the president has said he believes that no more can be achieved.