He said Sunday that by now "it should be clear that the change we need will not come from Washington, even when tragedy strikes Washington."
"Change will come the only way it ever has come, and that's from the American people," he said.
The invitation-only crowd Obama spoke to at the Marine Barracks parade ground included more than 4,000 mourners, with the victims' family members directly in front of the speakers' stage. The president and first lady Michelle Obama met privately with the families before the service, White House officials said, and both hugged family members as they left.
Authorities say their loved ones' lives were taken Monday by shotgun-wielding former Navy reservist, Aaron Alexis, a 34-year-old information technology contractor who struggled with mental illness. Police killed Alexis in a gun battle.
Obama said it's clear from the Navy Yard shooting that the country needs to do a better job to secure its military facilities and improve mental health services, but also address gun laws.
"I do not accept that we cannot find a common-sense way to preserve our traditions, including our basic Second Amendment freedoms and the rights of law-abiding gun owners while at the same time reducing the gun violence that unleashes so much mayhem on a regular basis," Obama said, adding the change may not happen soon but it will happen "because it is the change that we need."
Earlier Sunday, National Rifle Association Executive Vice President Wayne LaPierre rejected any call for gun control. "The problem is there weren't enough good guys with guns," LaPierre said on NBC's "Meet the Press."
The military leaders who spoke before Obama at the memorial service included Defense Secretary Chuck Hagel, Navy Secretary Ray Mabus and Adm. Jonathan Greenert, chief of naval operations.