The Taliban Embassy in Pakistan announced the release of 524 Afghan refugees, including 54 women and 97 children, from Karachi prisons.
The embassy said in a statement that the released Afghans left for Afghanistan on Saturday.
Pakistan recently detained many Afghan immigrants for illegal stay in the country.
Earlier, the United Nations Higher Commissioner for Refugees (UNHCR) expressed concern about the situation of Afghan refugees, especially their families and children in Pakistani prisons.
The detention of Afghan citizens in Pakistan has also drawn criticism from several political figures.
In the past year, with the Taliban retaking control of Afghanistan and increasing poverty, the wave of migration of Afghans to neighbouring countries has intensified.