The US president told the thousands of people at the service that they had come together "filled with sorrow".
He also praised the bravery of those who had helped victims in the "terrible minutes during the attack".
"It may be hard to comprehend the twisted logic that led to this tragedy, but this much we do know - no faith justifies these murderous and craven acts; no just and loving God looks upon them with favour," he continued.
"And for what he has done, we know that the killer will be met with justice - in this world, and the next."
Also attending the service was Army Chief of Staff George Casey, Defence Secretary Robert Gates, Adm Mike Mullen, chairman of the Joint Chiefs of Staff, and Texas Governor Rick Perry.
Maj Hasan is recovering from gunshot wounds at a military hospital and will be charged in a military court over last Thursday's shootings - he has declined to be interviewed by investigators.
On Monday, the Senate Homeland Security Committee announced it would hold a full investigation into the attacks, starting with a public hearing next week.
Senator Joe Lieberman, who chairs the committee, said the "murderous attack should be examined from every angle to make sure nothing like this occurs again".
He said investigators would seek to determine Maj Hasan's motives and "whether the government missed warning signs that should have led to expulsion, and what lessons we can learn to prevent such future attacks".
Mr Lieberman said the authorities would "do no favour" to Muslims serving in the US army by "ignoring real evidence" that Maj Hasan may have held violent extremist views.
An FBI-led task force monitoring the e-mail of Yemen-based US cleric Anwar al-Awlaki said he had communicated with Maj Hasan - a US-born Muslim and army psychiatrist - on 10 to 20 occasions.
However, it was decided that further investigation was not needed, as the content of the messages did not advocate or threaten violence.
FBI Director Robert Mueller has ordered a review of how the agency dealt with information about Maj Hasan.
A senior Republican on the House of Representatives Intelligence Committee has called on all the US intelligence agencies to preserve the information they have on Maj Hasan.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.