The announcement in this regard by Pakistan was made a day before the deadline of the return was to expire on June 30.
Pakistan had set the deadline to put pressure on the about 3 million Afghan refugees - 1.5 million registered and about as many undocumented - to return to their homeland.
Pakistan Prime Minister Nawaz Sharif granted the six month stay till December 31, 2016, an official said.
Sharif said that Pakistan will supply free wheat for three years to refugee camps set up in Afghanistan to accommodate those returning from Pakistan.
Also Read
Afghanistan had earlier asked to extend the stay for two more years so that it could prepare to receive the refugees. According to UNHCR there are 1.6 million registered and another 1 million unregistered refugees in Pakistan but local official of Pakistan put their total number to more than 3 million.
The deteriorating security situation in Afghanistan meant that between January and June only 7,000 Afghans have returned to their homeland, according to UNHCR Pakistan.
Pakistan last week called for international support as it warned that without help, the flow of those fleeing Afghanistan's decades-long war to Europe could increase.
Next month Pakistan will host a tripartite meeting with Afghanistan and the UN to discuss the situation.