"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.
- Saudi king says terrorists will reach Europe...
- Corvette Museum to completely fill in...
- Freelancers and millennials help usher in the...
- Six Ferguson officers face federal lawsuits...
- Intelligence nightmare: Extremists returning...
- Running again? Mitt Romney tells Hugh Hewitt...
- Obama to attend wedding of longtime personal...
- Mexico authorities stage midnight migrant raid
- A New York Times article said Michael... 44
- Running again? Mitt Romney tells Hugh... 36
- 10 things to know about corporate... 32
- Obama tamps down prospect of strikes in... 16
- Why the poverty cycle is harder to... 15
- Winning plaintiffs in 3 states want... 14
- 3 ways insurers can still avoid... 13
- It's about time the government... 12