Speaking at the vigil in Newtown High School, the president drew sobs and tears from the packed auditorium when he solemnly read the first names of all 20 children who were among those killed in the Friday attack, saying they had been "called home" by God. Lighted candles in tumblers placed in front of the podium represented the shooter's victims, which also included six adults.
But Obama also elicited laughter when he spoke about how the school children were "dutifully following instructions as young children sometimes do" and again when he told how one small child said, it was OK because he knew karate.
Obama started out quoting Scripture, saying "do not lose heart."
"For we know that if the earthly tent we live in is destroyed, we have a building from God, an eternal house in heaven, not built by human hands," he said.
The president went on to tell the audience the "20 beautiful children and six remarkable adults ... lost their lives in a school that could have been any school; in a quiet town full of good and decent people that could be any town in America."
He said his purpose in coming to Newtown was to "offer the love and prayers of a nation."
"I am very mindful that mere words cannot match the depths of your sorrow, nor can they heal your wounded hearts," he said. "I can only hope it helps for you to 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, we've pulled our children tight.
"And you must know that whatever measure of comfort we can provide, we will provide; whatever portion of sadness that we can share with you to ease this heavy load, we will gladly bear it. Newtown -- you are not alone."
Obama lauded the school staff's courageous efforts to save the children, as well as the work of the first responders who raced to the scene.
"As a community, you've inspired us, Newtown," he said. "In the face of indescribable violence, in the face of unconscionable evil, you've looked out for each other, and you've cared for one another, and you've loved one another. This is how Newtown will be remembered. And with time, and God's grace, that love will see you through."
The president then told the crowd the nation is faced "with some hard questions" about whether it is meeting its obligations.
"Can we honestly say that we're doing enough to keep our children -- all of them -- safe from harm?" he said.
"I've been reflecting on this the last few days, and if we're honest with ourselves, the answer is no. We're not doing enough.
"These tragedies must end. And to end them, we must change. We will be told that the causes of such violence are complex, and that is true. No single law -- no set of laws can eliminate evil from the world, or prevent every senseless act of violence in our society.
"But that can't be an excuse for inaction. Surely, we can do better than this. If there is even one step we can take to save another child, or another parent, or another town, from the grief that has visited Tucson, and Aurora, and Oak Creek, and Newtown, and communities from Columbine to Blacksburg before that -- then surely we have an obligation to try.
"In the coming weeks, I will use whatever power this office holds to engage my fellow citizens -- from law enforcement to mental health professionals to parents and educators -- in an effort aimed at preventing more tragedies like this.
"We can't accept events like this as routine."
People stood and applauded loudly when Obama finished speaking and the president stood at the side of the stage and waved his hand several times before exiting alone from the back of the stage.
At quiet points during the service, the hush was broken by the cries of restless small children and babies.
Outside the school, an overflow crowd of people, huddled in blankets and holding candles, listened to the service on a speaker.
The service was multi-faith, and included a pianist playing "Amazing Grace," "Lord of the Dance" and "Jesu, Joy of Man's Desiring."
First responders who attended were greeted by a standing ovation and some cheers from the crowd as they filed into the auditorium.
The White House, according to custom, did not reveal any details of the president's private meetings with first responders and families of the victims.
Before the service started, there was a buzz in the auditorium as adults stood in small groups, talking to one another, with some are crying, embracing and holding each other close.
Several small groups of children also were on hand, with some talking happily with friends, a stark contrast to the emotions shown by the grownups. Some children wore "Sandy Hook School" sweat shirts or were in Scout uniform, and several held small stuffed dogs handed out at the door by the Red Cross.
The president arrived on Air Force One landed at Bradley Air Force base outside Hartford at 3:53 p.m. He walked down the steps under a light drizzle and climbed aboard his sport utility vehicle for a motorcade to Newtown.
A White House official said the president was the primary author of his speech and did not use a teleprompter.
It was the fourth time he has represented the nation in the aftermath of such a massacre. The Washington Post said the president made similar visits to Fort Hood, Texas, in 2009, Tucson in 2011 and Aurora, Colo., in July in the aftermath of a gunman's spree.
The newspaper said Obama focused each time on emotion and healing, the Post said, barely mentioning the subject gun control.
But on Sunday morning, U.S. Sen. Joseph Lieberman, Ind-Conn., said now is the time re-enact an assault weapons ban that expired in 2004, the report said, and New York Mayor Michael Bloomberg said Obama should act while the country's attention is focused.
Meanwhile, police sought a motive in the Newtown school massacre.
Adam Lanza, 20, shot and killed six adults and 20 children at Sandy Hook Elementary School in Newtown Friday before turning his gun on himself. His mother Nancy was found dead in their home.
Authorities have been working since Friday to come up with any motive for the shootings, The Hartford (Conn.) Courant reported.
The president of the Connecticut Funeral Directors Association told The Courant that more than 60 funeral directors have volunteered to help the families of the victims bury their dead and caskets and vaults were being donated as well.
Trader Joe's: Car crashes into Long Island store, injuring 11
Wisconsin business offering 'therapeutic cuddling' forced to close