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. (Christina Lee/The Washington Post)

Again, the daunting task of consoling his citizens after another lone gunman brought carnage to another community fell to President Obama. This time, his fourth in as many years, Obama confronted the unimaginable: the senseless slaughter of 20 small children.

Yet Obama did more than act as mourner-in-chief at an interfaith vigil here Sunday night: He also vowed, in an angry tone that defined much of his speech, to use “whatever power this office holds” to enact changes aimed at preventing future massacres.

“We can’t tolerate this anymore. These tragedies must end. And to end them, we must change,” Obama said. He added: “We can’t accept events like this as routine. Are we really prepared to say that we’re powerless in the face of such carnage, that the politics are too hard? Are we prepared to say that such violence visited on our children year after year after year is somehow the price of our freedom?”

Behind his words was a signal of presidential intent that Obama, for the first time, would push for solutions aimed at preventing such incidents, such as new gun-safety laws. But, he said, he would save detailed policy discussions for another venue on another day; he did not utter the word “gun” during the 18-minute speech.

The president eulogized those killed Friday by a gunman who brought what Obama called “indescribable violence” and “unconscionable evil” to Sandy Hook Elementary School — “a school that could’ve been any school.”

Read the stories of the Newtown shooting victims

“I come to offer the love and prayers of a nation,” Obama said. “I am very mindful that mere words cannot match the depths of your sorrow, nor can they heal your wounded hearts. I can only hope it helps for you to know that you’re not alone in your grief.”

Obama did not openly cry, as he did during an appearance after the shootings Friday. But he took sporadic pauses to compose himself and spoke again as a father, having started his day by watching his daughter Sasha’s dance rehearsal. He ended it in a hall full of grieving parents, some of whom won’t ever get to see their children’s performances again.

In his own remarks during the vigil, Connecticut Gov. Dan Malloy (D) said Obama had told him that Friday was the most difficult day of his presidency. Hours after the Newtown shooting, Obama fell silent and wiped tears from his eyes as he read a brief statement from the White House press briefing room.

“Someone once described the joy and anxiety of parenthood as the equivalent of having your heart outside of your body all the time, walking around. With their very first cry, this most precious, vital part of ourselves, our child, is suddenly exposed to the world, to possible mishap or malice,” Obama said Sunday.

Every American’s first task, he said, is to protect and care for the nation’s children.

“Can we honestly say that we’re doing enough to keep our children, all of them, safe from harm?” Obama asked, adding: “If we’re honest with ourselves, the answer’s no. We’re not doing enough. And we will have to change.”

Steve Yudelson hugged his weeping daughter after Obama’s speech. “What can you say? The man is brilliant. That’s what a president does — he leads, he inspires,” he said.

Obama spoke inside the auditorium of Newtown High School from a lectern bearing the presidential seal, but without his typical trappings. There were no prompters; he read his speech from notes. He stood in front of a black curtain. Twenty-seven candles rested at the foot of his podium, one for each of those killed.

Earlier, Obama met with the victims’ families and first responders. He was photographed smiling as he held up the newborn granddaughter of Dawn Hochsprung, Sandy Hook’s principal, who was among those slain.

But when the service began, as clergy leaders read prayers and sang hymns, Obama sat in the front row looking despondent, his hands clasped together and his eyes misty.

For Obama, this was a familiar, awful ritual. He made similar journeys to Fort Hood, Tex., in 2009 after 13 service members were killed; to Tucson in 2011, after the attempted assassination of Rep. Gabrielle Giffords (D-Ariz.) and the killing of six of her constituents; and to Aurora, Colo., this July after 12 people were shot dead inside a movie theater.

Each time, a gunman used weapons of war to massacre his countrymen. And each time, Obama stood before a nation in mourning, helping it define and overcome a gruesome act that under his presidency has become all too common.

“There isn’t someone who’s dealt with this kind of situation as often as he has,” said Kathleen Hall Jamieson, a professor of presidential rhetoric at the University of Pennsylvania.

President George W. Bush comforted the nation after the terrorist attacks of Sept. 11, 2001, and President Bill Clinton consoled Americans after the 1995 bombing of a federal office building in Oklahoma City and the 1999 shooting at Columbine High School.

But no president in recent history has had to confront mass shootings of the scale and frequency of those under Obama.

“You’re helping the country in a quasi-ministerial role trying to bring meaning to an event that seems fundamentally meaningless,” Jamieson said. “It’s understanding the death, mourning the loss, asserting the resilience of the country and trying to make meaning of it.”

For all the cities shaken by mass shootings where Obama paid his respects, there are even more that he did not visit: Oak Creek, Wis., where a gunman killed six at a Sikh temple in August, and Binghamton, N.Y., where 13 were killed in an immigration center in 2009.

In Newtown on Sunday, Obama spoke of the schoolchildren amid the shooting, many of them first-graders, “helping one another, holding each other, dutifully following instructions in the way that young children sometimes do, one child even trying to encourage a grown-up by saying, ‘I know karate, so it’s okay; I’ll lead the way out.’ ”

A White House official said Obama was the primary author, although he worked on edits with speechwriter Cody Keenan aboard Air Force One as they flew to Connecticut. Keenan helped Obama write his eulogy in Tucson.

Perhaps the most poignant moment came near the end of Obama’s speech, as he read aloud the first names of all 20 dead children.

“Charlotte, Daniel, Olivia, Josephine, Ana, Dylan, Madeleine, Catherine, Chase, Jesse, James, Grace, Emilie, Jack, Noah, Caroline, Jessica, Benjamin, Avielle, Allison,” he said.

The president paused at times, struggling to hold his composure. Adults in the auditorium could be heard sobbing.

“God has called them all home,” Obama continued. “For those of us who remain, let us find the strength to carry on and make our country worthy of their memory.”

Rucker reported from Washington and Vogel from Newtown. David Nakamura and Scott Wilson in Washington contributed to this report.