NEWTOWN, Conn. — President Obama vowed on Sunday to “use whatever power this office holds” to stop massacres like the slaughter at the school here that shocked the nation, hinting at a fresh effort to curb the spread of guns as he declared that there was no “excuse for inaction.”

In a surprisingly assertive speech at a memorial service for the 27 victims, including 20 children, Mr. Obama said that the country had failed to protect its young and that its leaders could no longer sit by idly because “the politics are too hard.” While he did not elaborate on what action he would propose, he said that “these tragedies must end.”

The speech, a blend of grief and resolve that he finished writing on the short Air Force One flight up here, seemed to promise a significant change in direction for a president who has not made gun issues a top priority in four years in office. After each of three other mass killings during his tenure, Mr. Obama has renewed calls for legislation without exerting much political capital, but the definitive language on Sunday may make it harder for him not to act this time.