GILGIT - A military helicopter crashed Friday, killing seven people including the Norwegian and Philippine envoys and the wives of the Malaysian and Indonesian ambassadors, and setting a school building ablaze in a remote northern valley.

The Pakistani Taliban later claimed the group had struck the aircraft with a ground-to-air missile hoping to assassinate Prime Minister Nawaz Sharif who was flying to the region at the same time - but the claim was rebutted by officials and multiple eyewitnesses, including Foreign Secretary Aizaz Ahmad Chaudhry.

The helicopter was one of three carrying a delegation of ambassadors to inspect projects on a three-day trip to Gilgit-Baltistan where they were set to meet with Sharif.

The military and Foreign Office said the crash was due to a technical fault while landing. Officials added the school was shut at the time.

"There was no act of terrorism and the helicopter went down due to a technical fault," Aizaz Chaudhry told a press conference.

"The Taliban's claim is bogus as there were full security arrangements in place. It was just a technical failure," he added.

Chaudhry said helicopter's black box had also been found and "we will find out what kind of accident it was."

He said there were 19 people on board the chopper, of whom 12 were rescued.

A statement by Sharif's office had said he was on a plane en route to the Gilgit area at the time of the incident, but turned back to Islamabad after news of the crash broke.

He was due to inaugurate a chair-lift at a ski resort, one of the region's top administrative officials told AFP.

Leif H Larsen, the Norwegian envoy, and Domingo D Lucenario Jr of the Philippines were killed along with the wives of the Malaysian and Indonesian ambassadors, as well as the helicopter's two pilots and another crew member according to official tweets by the army. Norway's foreign office confirmed the death of its diplomat.

The Indonesian foreign ministry in a statement confirmed the death of the ambassador's wife, Heri Listyawati Burhan Muhammad, but said that Ambassador Burhan Muhammad was safe though he had sustained injuries.

Sharif "expressed deep grief and sorrow" and announced a day of mourning, according to his office.

Polish ambassador Andrzej Ananiczolish and Dutch ambassador Marcel de Vink were also injured, the army said. The Dutch Ministry of Foreign Affairs confirmed Vink's injury.

It was Pakistan's worst air crash since 2012 when a Boeing 737 passenger plane went down in Islamabad, killing 130 people.

In 1988, a plane crash killed Pakistan's then military-ruler General Ziaul Haq as well as the US ambassador at the time, Arnold Raphel.

A local police official on duty near the site told AFP: "I was watching the helicopters arriving, they were coming since the morning, it was their third or fourth trip.

"One helicopter suddenly whirling at its place and went down with a bang, then there were flames."

An emergency medic who was deployed nearby ahead of the inauguration ceremony said the helicopter only exploded and caught fire after landing.

"The pilot was gesturing at us to come and help him. We rushed there, broke the windows, and started dragging people out.

"After some minutes, there was an explosion, injuring some of the medics too."

Two other eyewitnesses interviewed by AFP also said they did not see the chopper being hit by a missile.

Farmer Shakil Ahmed saw the helicopter crash into the school roof from his house about 100 metres away. "The helicopter came very close to the helipad, maybe 250 metres in the air, just above the school," Ahmed told Reuters.

"It hovered there for a while and then tried to turn when it crashed. Thankfully there were no kids in the school because it was an off-day for security reasons. The helicopter caught fire and was on fire for over an hour."

An official in Gilgit said nine people had been killed. "The bodies are so badly torched that they can't be identified," said Sibtain Ahmed, the home secretary of Gilgit-Baltistan.

According to a list of passengers obtained by AFP, the ambassadors of Indonesia, Lebanon, Malaysia, the Netherlands, Romania, Norway, South Africa, the Philippines and Poland were scheduled to fly on the helicopter.

"It was a diplomatic trip with members of 37 countries in total," said a passenger in one of the helicopters, who requested anonymity, concurring that the school had caught fire after the crash.

The passenger added that the air convoy was supposed to have included four helicopters but the number was later reduced to three. In the city of Gilgit, the region's administrative capital, some 50 kilometres to the southwest, a hospital official said the injured were carried on stretchers to the emergency ward of the Combined Military Hospital.