US and Afghan forces have freed the kidnapped son of a former Pakistani prime minister in Afghanistan, the Pakistani foreign ministry has said in a statement.

Ali Haider Gilani, the son of Yousaf Raza Gilani, "has been recovered today in a joint operation carried out by the Afghan and US security forces", the statement on Tuesday said, adding that preparations were being made to return him to Pakistan following a medical check-up.

Bilawal Bhutto Zardari, the chairman of the prominent Pakistan Peoples Party (PPP), tweeted that Ali Haider Gilani had been "recovered in a successful operation".

The rescue operation was carried out overnight Monday in the eastern border region of Paktika province, and according to the Afghan government, Gilani was being held by al-Qaeda affiliated group.

Al Jazeera's Qais Azimy, reporting from Kabul, said the news demonstrated the capabilities of Afghan security forces in the restive border region, and could possibly pave the way for a thawing of relations between Afghanistan and Pakistan.

"The Afghan government has spent the past few years trying to build trust with Pakistan, and this could be one of the reasons why they pushed to secure the release of Gilani," he said.

The news comes just over three years after Gilani was kidnappedby suspected Taliban fighters in a hail of gunfire on May 9, 2013 in Pakistan, two days before the national election in which he was campaigning.

Gunmen on a motorbike opened fire before abducting him in a black Honda car on the outskirts of Multan in Punjab province. His secretary and a bodyguard were killed, and four people wounded.

In May last year he was able to phone his father to tell him he was well.

Gilani senior was prime minister from March 2008 until he was sacked and indicted by the Supreme Court in April 2012 for refusing to re-open corruption cases against the then-president.

He had complained after the kidnapping that his family was not given security despite being threatened.

Source: Al Jazeera and agencies