
The quake came more than two weeks after an earlier earthquake disaster, in which parts of Nepal were levelled and more than 8,000people were killed.
A further 17 people died on Tuesday in neighbouring India, and one person was reported dead in China, officials said.
"We have reports of 40 killed and 1,129 injured so far," Laxmi Dhakal, Nepalese Interior Ministry spokesman said, adding that 32 of Nepal's 75 districts were hit by the quake.
"Dolakha and Sindhupalchowk, the epicentres of the quake and the aftershock, are badly hit," Dhakal said. "They were already in badshape due to earlier quakes. We expect complete devastation in some of the villages in these areas."
The quake set off at least a dozen landslides, he said.
The epicentre of the quake that struck at 0705 GMT was near the Chinese border, about 75 kilometres east of Kathmandu, the United States Geological Survey said.
In the Everest region, four children were injured when a school wall collapsed, local police officer Bhankbhakta Nepal said from the town of Lukla.
"Children ran out of classrooms. Eleven people were injured in a nearby village here. Two others are in serious condition," he said.
"My brother's house in Sindhuli (120 kilometres south-east of Kathmandu) was already damaged by the first quake," Kathmandu resident Kalpana Giri said.
"But the house is gone after today's quake," she said. "He is a disabled man. I don't know what he will do. Where will he live?"
People were seen running screaming onto the streets of Kathmandu and nearby towns, already ravaged by the April 25 quake that destroyed an estimated half a million houses.
Telephone connections were down and traffic was at a standstill.
"Looks like Nepal will be destroyed completely this time," one resident said, while others were putting up tents in open spaces that they had only recently taken down.
Shopkeepers were closing their businesses as people tried to stock upon food. Mobile phones were not working.
Injured people were admitted to Kathmandu Hospital, said Man Bahadur Pun, a police officer on duty in the area.
Several buildings had fallen down in the capital.
"One old woman is buried inside. We are trying to get her out," police inspector Suraj Poudel told dpa from the site of a collapsed building in the city.
"Four of the dead are in Kathmandu," national police spokesman Kamal Singh Bam said, adding that at about 700 people had been reported injured.
Nepalese Prime Minister Sushil Koirala urged fearful citizens "not topanic," during a Kathmandu press conference.
"Please do not panic. We believe we will slowly be saved from this natural disaster," he said, asking Nepalese "not to disrupt the rescue operation."
"Rescue teams have been deployed. We will use all the resources and equipment available to the government for search and rescue. This is a natural disaster. We have to face this with courage and with patience."
Nepal's only international airport in Kathmandu was shut down for more than an hour. Schools have been asked by the education ministry to shut down for the next two weeks.
In India, 17 people were killed and dozens injured, officials said.
Federal Home Ministry spokesman KS Dhatwalia said 16 deaths occurred in Bihar while another casualty was reported from Uttar Pradesh as houses and buildings collapsed.
Sunil Kumar, joint secretary of Bihar state's disaster management department, said many houses and buildings were damaged.
Metro services were suspended in New Delhi as television footage showed children evacuated from schools.
"It was really scary," said Manbir Singh, who works in the Delhi suburb of Gurgaon said.
"My desk and computer were all shaking."