Police said an electric short circuit triggered a pre-dawn fire in a house in Gayal village, 168 kilometres south of Gilgit, which spread to a nearby building where the explosives were being stored.
Some 200 people rushed to extinguish the blaze and while they were fighting the fire, the explosives - owned by a government contractor building roads - caught fire and exploded, witnesses said.
"Forty-five people were reported dead after the blast overnight and four died during transportation of casualties to the hospital," said doctor Hamid Khan of the nearby Chilas valley district hospital.
"Three more died in our hospital early Sunday," the doctor told Agence France Presse.
Around 70 people were brought to the Chilas hospital with serious injuries and "many have been referred to hospitals in Gilgit," Khan said.
"The casualties continued to pour in until late this morning," he said, adding that the facility was not properly equipped to handle the situation.
President Musharraf expressed grief
"It was an unprecedented big disaster in the area."
The casualty medical officer said an emergency had been declared at the hospital and authorities had rushed in life-saving drugs and equipment.
"The situation has now stabilised," he said.
Khan said some casualties had also been admitted to a local rural hospital but he had no figures on whether there had been any fatalities there.
Witnesses said weeping and wailing residents desperately sifted through the debris in search of missing people after the blast.
Buried in the rubble
Police and paramilitary troops were engaged in rescue operations. The authorities also sent military helicopters to move the injured to hospitals.
"The blast was massive, it triggered panic among the rescue workers (putting out the fire)," said a resident Abdul Bar, who lost his cousin in the explosion.
Another witness, Jumma Khan, said the casualties were high because several houses had collapsed after the blast.
"Many people were buried inside the demolished houses," he said.
Houses in the village, which is located in a narrow valley and has a population of 3,000 people, are mostly built with mud and stones and have wooden roofs.
Local officials said the contractor, Mohammad Waris, had intended to use the explosives to blast rocks in a road-building project in the mountainous region.
"He was granted a contract to build a link road in the area," an official said.
President General Pervez Musharraf and Prime Minister Zafarullah Jamali expressed "deep grief" over the loss of life and ordered an investigation, officials said.
Residents said a mass funeral was scheduled in Gayal late Sunday for the victims.