Two assailants riding a motorbike opened fire on Nayyar Iqbal Rana, 52, at a shop in the eastern city of Jalalabad, Pakistan's ambassador to Afghanistan Zahid Nasrullah Khan told AFP.
"When he went to the hospital he was pronounced dead," Khan said.
Nangarhar governor spokesman Attaullah Khogyani confirmed the deadly attack.
"Police have launched an investigation into the incident. No arrests have been made so far," Khogyani told AFP.
Pakistan condemned the assault in a statement issued by its foreign ministry that called on Afghanistan to take "urgent steps to apprehend the perpetrators".
Rana was the assistant to the consul general in Jalalabad, the capital of restive Nangarhar province, which borders Pakistan.
The foreign ministry statement said Rana had finished "his three year tenure in Jalalabad and was due to return to Headquarters".
Despite escalating violence across Afghanistan diplomats are rarely killed in the country where they are protected by very tight security.
The incident comes a few months after two Pakistani diplomats working at the same consulate in Jalalabad were kidnapped and later freed.
It also comes as relations between Afghanistan and Pakistan remain tense.
Kabul accuses Islamabad of supporting militant groups including the Taliban, believed to have links to Pakistan's shadowy military establishment who aim to use them as a regional bulwark against arch-nemesis India.
Pakistan has repeatedly denied the charge.
(This story has not been edited by NDTV staff and is auto-generated from a syndicated feed.)