Islamabad, Pakistan CNN  — 

After a 14-hour ordeal, all eight people, including six children and two adults, who were stranded on a cable car dangling hundreds of feet over a valley in northwest Pakistan have been rescued, the country’s caretaker Prime Minister Anwaar ul Haq Kakar said in a statement.

“Relieved to know that Alhamdolillah all the kids have been successfully and safely rescued. Great team work by the military, rescue departments, district administration as well as the local people,” he said in the statement posted on X, formerly called Twitter.

The rescue began on Tuesday morning local time after six children and two teachers were traveling to school in the province of Khyber Pakhtunkhwa when one of the gondola’s cables snapped, leaving them stuck some 900 feet above a valley, officials said.

The rescue included helicopters and the use of zip lines, officials say. But as night fell, Pakistani authorities were forced to pause helicopter rescues of the remaining children and adults.

The cable car was traveling between the villages of Btangi and Jhengarie and had made multiple trips on Tuesday before the cable snapped, said Tanveer Ur Rehman, deputy commissioner of Battagram district, who added that strong winds had thwarted earlier attempts to reach those trapped.

Six children and two adults are in the chairlift suspended over a deep valley in Pakistan.

Many children who live in remote and mountainous parts of Khyber Pakhtunkhwa province rely on cable cars to ferry them to school and back. Some of these lack regular maintenance and can be a risky form of travel.

Footage released by the rescue services captured the dramatic moment when one child appeared to jump from the cable car while holding onto the end of a rope dangling from a helicopter before being flown to safety.

Another video provided by the rescue services showed locals and emergency workers using ropes to reel in another person attached to a platform by a harness.

The cable car had made multiple trips on Tuesday before the cable snapped.

Amid the rescue attempt on Tuesday, two of the students in the cable car were reportedly slipping in and out of consciousness, one of the passengers told Pakistani media outlet Geo News earlier. The passenger, named only as Gulfaraz, had urged state authorities to take action. He said that the students, aged between 10 and 15 years old, didn’t even have drinking water.

Rescue personnel gave the passengers nausea medication following reports of children vomiting, Ur Rehman said, adding that those trapped were also given heart-related medication.

The incident prompted Pakistan’s caretaker prime minister to order all “dilapidated and non-compliant chairlifts” to close immediately, according to a statement from his office.