On Sunday night, President Obama spoke at a vigil for those who died in the Newtown, Conn., tragic shooting at the Sandy Hook elementary school. (The Washington Post)

President Obama offered words of solace to a heartbroken and inconsolable community Sunday, meeting with loved ones of the dead from Sandy Hook Elementary School and lamenting at a nationally televised memorial service that the United States has failed in its duty “to keep our children, all of them,” safe from harm.

“Whatever measure of comfort we can provide, we will provide,” Obama vowed, addressing a grief-stricken audience of hundreds in the auditorium of the town’s high school. Many more listeners crowded near speakers in the school’s gym, while others huddled outside in a cold drizzle, holding candles and weeping at times.

“Whatever portion of sadness we can share with you to ease this heavy load, we will gladly bear,” the president told them.

“Newtown, you are not alone.”

Two days after the massacre of 20 children and six adults by a young man firing a military-style semiautomatic weapon in a hallway and classrooms at Sandy Hook Elementary, Obama, apparently alluding to gun-control laws, vowed to “use whatever power this office holds . . . in an effort aimed at preventing more tragedies like this.”

Read the stories of the Newtown shooting victims

“No single law, no set of laws, can eliminate evil from the world or prevent every senseless act of violence in our society,” he said. “But that can’t be an excuse for inaction. Surely we can do better than this.”

The president’s visit to this community of 27,000 people, about 30 miles west of New Haven, came as the debate over gun control raged anew and as investigators continued the laborious job of sorting out precisely what happened Friday morning at Sandy Hook, and why.

Earlier Sunday, authorities disclosed that the 20-year-old gunman, Adam P. Lanza, stormed into the elementary school with “numerous” high-capacity ammunition magazines for the .223-caliber Bushmaster assault rifle that he used to carry out the carnage. He then fatally shot himself.

They said Lanza had hundreds of bullets in 30-round magazines when he shot out a pane of glass and entered the locked school at 9:30 a.m. He also had two semiautomatic pistols, officials said, but he apparently fired only the rifle.

Before driving to the school, Lanza fatally shot his mother, Nancy Lanza, 52, in her pajamas in her bed, at the Newtown home they shared, police said. The two pistols and the Bushmaster were among a half-dozen firearms legally registered to Nancy Lanza, authorities said. It remained unclear Sunday which weapon was used to take her life. She suffered multiple gunshot wounds to the head, an autopsy found.

The specifics of Adam Lanza’s weaponry, publicly disclosed by police, raised questions about how he had obtained so many magazines. And it suggested that the attack could have been even worse. When he died, Lanza still had numerous rounds of unspent ammo, and authorities later found a shotgun in the car he used.

Why he chose the school remained a mystery Sunday, at least to the public, as authorities disclosed only the barest details of what they said almost certainly will be a protracted investigation. Initial reports that Nancy Lanza had been a kindergarten teacher at Sandy Hook Elementary turned out to be erroneous.

The school’s 436 surviving students will not return to Sandy Hook, Newtown’s school superintendent announced Sunday. There will be no school Monday and perhaps not for the rest of the week; it will be a week of funerals in Newtown. The first is Monday, for 6-year-old Noah Pozner. Eight other funeral services were being planned at Newtown’s St. Rose of Lima Roman Catholic Church, where 10 of the 20 young victims were parishioners.

When it is time for school again, the Sandy Hook students will attend an unused school in a neighboring town.

As dusk gave way to darkness after a cold, damp day of bottomless communal grief, hundreds of mourners of all ages slowly converged on Newtown High School for the service of remembrance. Among them was Kristen Rosengrant, with her young sons.

“As a mom, I’ve been so upset,” she said, waiting in line to get in. “I don’t think anything is going to help the families. But it’s nice to show concern.”

In the packed auditorium, Obama asked, “Can we honestly say that we’re doing enough to keep our children, all of them, safe from harm?” He added: “I’ve been reflecting on this the last few days, and if we’re honest with ourselves, the answer’s ‘no.’ We’ve not done enough. And we’ll have to change.”

Without referring specifically to gun-control legislation, the president said he intends to “engage my fellows citizens, from law enforcement to mental-health professionals to parents and educators” in search of new ways to combat gun violence. “Because what choice do we have? We can’t accept events like this as routine.”

Although every mass shooting prompts a public discussion of gun control, the issue has been politically dormant for years, with elected officials who favor stricter regulations appearing reluctant to pursue a debate that they consider unwinnable.

But the enormity of the Newtown shootings — the slaughter of 20 defenseless grade-schoolers, ages 6 and 7, and the country’s horrified, heartsick reaction — seems to be generating a louder-than-usual chorus of calls for tougher gun laws.

Sen. Joseph I. Lieberman (I-Conn.) said Sunday that the time is right to reenact the federal ban on assault weapons, which expired in 2004. New York Mayor Michael R. Bloomberg (I) said Obama should push for such legislation now, while the nation stares aghast at the devastation wrought by a killer wielding a military-style rifle.

Sen. Dianne Feinstein (D-Calif.) vowed to introduce a bill to ban such weapons, and Connecticut Gov. Dan Malloy (D) told CBS News’s Bob Schieffer that the rampage seems to prove that his state’s strict gun laws are not strict enough. “Obviously they didn’t prevent this woman from acquiring that weapon and obviously allowed the son to come into possession of those,” Malloy said. He added, “When someone can use an assault weapon to enter a building . . . [and] have clips of up to 30 rounds on a weapon that can almost instantaneously fire those, you have to start to question whether assault weapons should be allowed.”

Most opponents of gun control on Capitol Hill have stayed silent. The executive producer of NBC’s “Meet the Press” tweeted that the show “reached out to ALL 31 pro-gun rights Sens in the new Congress to invite them to share their views” on the program Sunday, but none agreed to appear.

Rep. Jason Chaffetz (R-Utah), a gun-rights advocate who visited Newtown on Sunday, recalled his reaction to the killings: “I wept. I said a prayer.” But the tragedy will not alter his position on regulating firearms, he said. He said Congress instead ought to pay more attention to how the nation treats the mentally ill.

“I’m in exactly the same place on [firearms] as I was before,” he said, adding that he senses no new support among Republicans for gun-control legislation.

The magazine-fed .223-caliber rifle from which a law enforcement official said Lanza fired “dozens and dozens” of rounds was manufactured by North Carolina-based Bushmaster Firearms International. It is a semiautomatic civilian version of a more potent weapon, the U.S. military’s standard-issue M-16 rifle.

Semiautomatic refers to the weapon’s mechanics. A separate trigger pull is required to fire each bullet. Inside the rifle, the compressed gas produced by each explosive discharge is channeled under high pressure through a tube. The pressure activates a mechanism that lifts a fresh round from the magazine and shoves it into the firing chamber.

This happens so quickly that after each round is discharged, the rifle is to ready fire again in an imperceptible fraction of a second — meaning it is capable of firing as rapidly as the shooter is able to squeeze the trigger, let go and squeeze again.

The main difference with the military model, in use since the early 1960s, is that the M-16 has a thumb switch that converts the rifle to automatic, allowing the shooter to fire bullets in a continuous blur, machine-gun-style, simply by squeezing the trigger and holding it.

Regardless of the version, however, the killing power of those high-velocity, .223-caliber slugs is the same, whether fired in Sandy Hook Elementary last week or 40-plus years ago in the jungles of Vietnam.

Each of the Newtown victims, ages 6 to 56, was shot at least twice and some were hit by as many as 11 bullets, authorities said.

“I’m very mindful that mere words cannot match the depth of your sorrow, nor can they heal your wounded hearts,” the president said in the auditorium.

“I can only hope you know that you’re not alone in your grief, that our world, too, has been torn apart — that all across this land of ours, we have wept with you, and we’ve pulled our children tight.”

Duggan and Fahrenthold reported from Washington. Michael Leahy in Washington contributed to this report.