Ali Haider Gilani, the son of a former Pakistani leader, appears shortly before his 2013 kidnapping.
CNN  — 

The kidnapped son of former Pakistani Prime Minister Yousuf Raza Gilani was rescued Tuesday in a joint operation by Afghan and U.S. security forces, according to the Pakistani Prime Minister’s press office.

Ali Haider Gilani was abducted in May 2013, shortly before he was set to run in provincial assembly elections.

Gilani was rescued in the Giyan District of Afghanistan’s Paktika province, a U.S. statement said.

His rescue came about almost by accident.

A helicopter raid by U.S. Special Operation Forces and Afghan troops was targeting someone believed to be a significant al Qaeda operative in the area, according to a senior U.S. military official.

There was limited intelligence a hostage might be at the target site, but the forces were not certain and did not know the identity of the possible hostage.

The forces attacked a compound-like structure, and all the fighters fled into a nearby field, the U.S. official said.

The Special Operation Forces chased the fighters down, and a brief firefight followed, the official said. A person in the field, who later turned out to be Gilani, was unarmed and made it clear he wanted to surrender.

Four “enemy combatants” were killed in the counterterrorism mission, the U.S. statement said.

Tawab Ghorzang, spokesman for Afghanistan’s Office of National Security Council, said that Gilani will be returned to his family soon. He will be transferred to Pakistan following a medical checkup.

His father was Pakistan’s Prime Minister from 2008 to 2012.

CNN’s Sophia Saifi in Islamabad and Barbara Starr contributed to this report.