Mr Gilani was abducted in 2013 ago in his home town of Multan as he was campaigning in elections for the Pakistan Peoples’ Party (PPP).
Pro- Taliban groups were believed to be behind the kidnapping.
PPP chairman Bilawal Bhutto Zardari tweeted that Yusuf Raza Gilani had “received call from ambassador of Afghanistan. His son… has been recovered in a successful operation.”
Ali Haider Gilani is the youngest son of Yusuf Raza Gilani who was prime minister of Pakistan from 2008 until 2012.
He had been contesting a seat in the Punjab provincial assembly in the 2013 elections, when he was seized by gunmen who opened fire on a campaign rally in the May – just a few days before the polls opened.