"In the heart of Battagram, our heroes rose to the challenge. Our military, administration and local champions, hand in hand, defied danger to write a new chapter of valour," Anwaar-ul-Haq Kakar wrote on the social media platform X, formerly Twitter.
"They rescued eight young souls, proving once more the strength of our unity. Our nation's spirit shines brightest today. Proud of our heroes!"
The army was called in to the rescue operation in the mountainous area of Khyber Pakhtunkhwa province, where locals use cable cars as transport in the absence of roads and bridges.
An army helicopter was used to rescue one child before zip lines were used to bring out the remaining passengers.
Television footage showed the child being lifted off the cable car by a helicopter in a harness and then carried to the ground.
Civilians reportedly played a large part in later rescue efforts, navigating the zip line to help rescue those stranded.
At least 150 children use the cable car every day to go to school, local teacher Zafar Iqbal told Pakistan's Dawn News.
In touch with the stranded pupils via mobile phone, he said one child had fainted out of fear while stuck inside the cable car.
President Arif Alvi said he was ecstatic to hear about their safe rescue.
"Must appreciate all, our military personnel, local rescuers, and entire administration, for showing commitment and bravery in this most critical rescue," he tweeted.
The government must launch a "comprehensive survey" of all local cable cars to ensure people's safety, he added.
Social media users largely praised civilian rescuers who volunteered in the operation, criticising the army for rescuing only one child in a period of many hours.
One user called on the president to give awards to the local resident rescuers, while others shared video describing them as heroes.
"The young man who risked his life and with selfless service and bravery brought several children with his dedication and courage. He deserves a civil gallantry medal," one user said.
"The local rescuers are the real heroes here and should be mentioned alone ... had they been allowed to operate earlier the rescue would have been finished in a few hours," wrote another.