Imran Khan has pledged to grant citizenship to 1.5 million Afghan refugees who have lived on the margins of Pakistan’s society for decades.

According to the UN, Pakistan has the largest refugee population in the world, mostly made up of 2.7 million refugees from Afghanistan. Many fled the Soviet invasion in 1979, while others came across the border due to violence and economic turmoil.

In a surprise announcement on Sunday at a public event in Karachi, the Pakistani prime minister said: “Afghans whose children have been raised and born in Pakistan will be granted citizenship inshallah (God willing) because this is the established practice in countries around the world.

“They are humans. How come we have deprived them and have not arranged for offering them national identification card and passport for 30 years, 40 years?”

According to UN surveys, about 60% of the Afghan refugee population was born in Pakistan, meaning almost 1.5 million people stand to benefit. Khan also promised the same treatment for Bengali refugees, which would include the Rohingya minority.

Pakistan’s citizenship act of 1951 guarantees citizenship to anyone born in the country. However, bureaucratic hurdles, ethnic rivalries and the exception against children whose parents come from “alien” or enemy nations has made it close to impossible for Afghan and Bengali refugees to secure their rights, along with the Pakistani passport they would bring.

Khan noted in his speech, broadcast on national television, that a lack of official documentation pushed many refugees towards black-market labour or crime.

Human rights groups and commentators across the political spectrum welcomed the announcement as the first real sign of Khan’s promise to shake up the status quo and bring in a new, progressive Pakistan. He swept to victory in elections in July as the candidate for the Pakistan Tehreek-e-Insaf (PTI) party.

The pledge marks a reversal of decades of hostility towards Afghan refugees in particular, who are often blamed for producing or shielding terrorists. The official government policy has long been to promote “voluntary” repatriation. In 2016, about 600,000 Afghans were sent back, in a process criticised as abusive by Human Rights Watch (HRW).

Questions were being asked in Pakistan about whether Khan had cleared his proposal with the powerful military, which has traditionally held sway over refugee policy.

The day before the prime minister’s speech, the foreign minister, Shah Mehmood Qureshi, who is seen as close to the army, returned from a visit to Kabul stressing the need for “dignified, sustainable repatriation”.

Sources within the UN were pleased at the initiative, but expressed some scepticism as to how fully it would be carried out.

Some analysts posited a political incentive for Khan. Afghan refugees belong to the Pashtun ethnicity and Pashtuns, thousands of whom live in Karachi, overwhelmingly “voted for PTI” two months ago, said Saroop Ijaz of HRW. Offering more Pashtuns citizenship could cement the party’s hold on the crucial megalopolis, he added.