"This is a horrific tragedy," Mayor Vincent Gray said.
The FBI also said Tuesday Alexis had a shotgun when he entered the building and got a handgun inside after he started firing. Valerie Parlave, head of the FBI's field office in Washington, said they don't have any information that he had an AR-15 assault rifle in his possession.
For much of the day Monday, authorities said they were looking for a possible second attacker who may have been disguised in an olive-drab military-style uniform. But by late Monday night, they said they were convinced the shooting was the work of a lone gunman, and the lockdown around the area was eased.
"We do now feel comfortable that we have the single and sole person responsible for the loss of life inside the base today," Washington Police Chief Cathy Lanier said.
President Barack Obama lamented yet another mass shooting in the U.S. that he said took the lives of American "patriots." He promised to make sure "whoever carried out this cowardly act is held responsible."
The FBI took charge of the investigation.
The attack came four years after Army psychiatrist Maj. Nidal Hasan killed 13 people at Fort Hood in what he said was an effort to save the lives of Muslims overseas. He was convicted last month and sentenced to death.
At the time of the rampage, Alexis was an employee with The Experts, a company that was a Defense Department subcontractor on a Navy-Marine Corps computer project, authorities said.
Parlave said Alexis had access to the Navy Yard as a defense contractor and used a valid pass.
The Washington Navy Yard is a sprawling, 41-acre labyrinth of buildings and streets protected by armed guards and metal detectors, and employees have to produce their IDs at doors and gates. More than 18,000 people work there.
The rampage took place at Building 197, the headquarters for Naval Sea Systems Command, which buys, builds and maintains ships and submarines. About 3,000 people work at headquarters, many of them civilians.
Witnesses on Monday described a gunman opening fire from a fourth-floor overlook, aiming down on people on the main floor, which includes a glass-walled cafeteria. Others said a gunman fired at them in a third-floor hallway.
Patricia Ward, a logistics-management specialist, said she was in the cafeteria getting breakfast.
"It was three gunshots straight in a row — pop, pop, pop. Three seconds later, it was pop, pop, pop, pop, pop, so it was like about a total of seven gunshots, and we just started running," Ward said.
Associated Press writers Matt Apuzzo, Adam Goldman, Jesse Holland, Stacy A. Anderson, Brian Witte and Ben Nuckols in Washington contributed to this report.
- Some countries get Obama, but want his wife, too
- Captain of sunken South Korean ferry, 2 crew...
- Colorado deaths stoke worries about pot edibles
- 13th body pulled from snow in Everest avalanche
- Texas seizes FLDS Church's secluded ranch
- Ride-sharing business launches despite...
- Get married, stay married? No fault divorce...
- Appeals judges question right to sue in...
- Obama: Religious intolerance has... 78
- Utah, Oklahoma same-sex marriage cases... 47
- The dangers of financially illiterate... 31
- Obama: 8 million signed up for health care 28
- Appeals judges question right to sue in... 27
- Texas seizes FLDS Church's secluded ranch 23
- Police: Student ate more pot than... 19
- Sentenced but never jailed, robber who... 16