The Pakistani Taliban abducted Ajmal Khan, vice-chancellor of Islamia College University Peshawar, the capital of northwestern troubled Khyber Pakhtunkhwa province, in September 2010.
The military said "security forces safely recovered" the professor, but gave no details of how he came to be freed.
Khan, 63, was similarly reluctant to discuss details of his release but said he was delighted to be reunited with his family.
"Thanks be to God, I have come back to home. They did not torture me, but being away from home is itself a torture. I can't explain how it is to see my children after four years," he told reporters.
More From This Section
Khan, who wore a long beard and appeared in good health despite his long captivity, said the militants had treated him well, giving him medication for his heart condition and a radio to let him keep up with current affairs.
He had appeared in several video messages asking the government to negotiate his release with the TTP, which began a bloody insurgency against the state in 2007.
Government officials said despite many rounds of back-channel talks in the past, Taliban had refused to release Khan, demanding the release of important Taliban commanders held by security forces.
"I was very worried initially but then I adjusted to the situation -- they used to make my contact with my family after every eight or nine months," he said.
"During the abduction, one day two children came to me and I started teaching them. The number of such children grew and at the end I was teaching English and maths to 32 of the Taliban's children," he added.