Shah was found in the backseat of a car in a town bordering the northwestern tribal areas
Pakistani soldiers rescued the kidnapped son of a senior judge from his Taliban captors on Tuesday, after finding him bound in chains with his mouth taped shut and wearing in an all-enveloping burqa to hide his identity, the army spokesman said.
Awais Shah, the son of Sindh provincial Chief Justice Sajjad Ali Shah, was kidnapped from outside a supermarket in the southern port city of Karachi on June 21.
Shah was found in the backseat of a car in a town bordering the northwestern tribal areas.
Army spokesman General Asim Bajwa said three "terrorists" were killed during the rescue, adding that the kidnappers belonged to a splinter faction of the Tehreek-e-Taliban Pakistan (TTP).
Bajwa told reporters the operation took place at approximately 2 a.m. near the town of Tank, when the kidnappers were transporting Shah, possibly with a view to transferring him to Afghanistan.
Tank, a town in the Khyber Pakhtunkhwa province on the border with the South Waziristan tribal area, is approximately 885 km (550 miles) north of Karachi.
Television footage showed Shah reunited with his family at their Karachi home.
Shah's father said he did not know which group kidnapped his son.
"I don't know anything other than that my child has been returned to me," he said.
At the time of his kidnap, police suspected the group involved intended to use him as a bargaining chip in negotiations to free imprisoned Islamist militants.
Kidnappings by criminal gangs or militants are common in Pakistan, and particularly in Karachi, a teeming metropolis of 20 million people plagued by political, ethnic and religious violence.
Pakistan has also been fighting an Islamist insurgency led by the TTP, an umbrella group of militant organisations seeking the overthrow of the government, since 2007.
Violence has dropped significantly countrywide since 2014, when the military launched an operation in the tribal areas along the Afghan border, but attacks against both civilians and security forces are common.
In March, Shahbaz Taseer, son of slain Punjab governor Salmaan Taseer, escaped captivity four years after being kidnapped by militants in the eastern city of Lahore.
Two months ago, U.S. and Afghan forces rescued Ali Haider Gilani, the kidnapped son of former Pakistani Prime Minister Yusuf Raza Gilani, who was kidnapped ahead of the country's 2013 general election.