US and Afghan forces freed the kidnapped son of a former Pakistani prime minister during a counter-terrorism mission in eastern Afghanistan, NATO said Tuesday, three years after he was kidnapped in a hail of bullets.

Ali Haider Gilani, son of Yousaf Raza Gilani, was rescued in the Giyan district of Paktika province "by US Special Operations Forces and Afghan commandos in a partnered raid," NATO said in the statement from Kabul.

The Afghan presidency said the raid targeted an Al-Qaeda cell, and that Gilani had been sent to the Pakistani embassy in Kabul.

The Afghan ambassador to Islamabad, Omar Zakhilwal, told AFP that Gilani was in good health.

"He is fine, he can walk, he can talk," Zakhilwal said, adding that he expected the former hostage to return to Pakistan late Tuesday or Wednesday.

Yousaf Raza Gilani broke the news to a cheering crowd at a political rally in Pakistan-held Kashmir Tuesday.

"This rally has proved fortunate for me," he said.

"When I was about to board the helicopter (to come), I received the information that my son Ali Haider Gilani, who was kidnapped three years ago, has been recovered."

Hundreds of people converged on the family's home in Multan in central Punjab province as the news broke, dancing to drumbeats and passing around sweets in celebration.

Some also hugged and presented flowers to Ali Haider's brother, Abdul Qadir Gilani, who told media he was "so happy today that I can't explain it in words".

"He is still in Afghanistan and soon he will be among us," he said of his brother.

"God has accepted somebody's prayer. The prayer of those who love us," a third brother, Ali Musa Gilani, told media.

NATO said the raid was carried out under Operation Freedom's Sentinel, the US mission focusing on counter-terrorism as well as training, advising and assisting Afghan troops.

"Four enemy combatants were killed as a result of the operation," it said.

The Pentagon was tight-lipped about events leading up to the raid, but said it occurred after US and Afghan forces had "identified terrorist activity."

Story continues

"There were terrorists where they struck and conducted this raid, and during that activity they were able to rescue Mr Gilani," US Central Command spokesman Colonel Pat Ryder said.

US Defence Secretary Ashton Carter said Gilani would go home after receiving a medical evaluation, and he heralded the raid as evidence of progress by Afghanistan's struggling security services.

"This raid demonstrates the growing capabilities and effectiveness of the Afghan security forces and is an excellent example of the strong security and intelligence partnership between Afghan and US forces," Carter said.

- 'Welcome back' -

Gilani was kidnapped by militants in the outskirts of Multan on May 9, 2013, just two days before a bitterly contested national election in which he was campaigning.

Gunmen on a motorbike opened fire before abducting him in a black Honda car. 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.

The ex-premier's family is one of the most powerful in Multan and a key clan in the Pakistan People's Party (PPP), which lost the 2013 election.

Gilani's recovery comes two months after the kidnapped son of another Pakistani politician was also freed.

Shahbaz Taseer, son of slain Punjabi governor Salman Taseer, spent five years in militant captivity before his abrupt release in March.

"Welcome back @haidergilani," Shahbaz Taseer tweeted Tuesday, adding an image of the Pakistani flag.

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 complained after the kidnapping that his family was not given security, despite being threatened.