"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.
- Ex-KKK leader David Duke runs for Senate: 'My...
- AP source: Clinton's choice for VP to be...
- Hillary Clinton selects running mate for...
- Self-assured, Kaine brings a steady hand to...
- Trump takes time from victory lap to swat at...
- California governor denies parole for Manson...
- AP Poll: Support grows among Americans for...
- IS attack on Afghan protest kills 80 people,...
- Sarah Silverman: Bernie-or-bust Dems... 49
- Is Bernie Sanders an atheist? 40
- Clinton wins historic nomination,... 32
- After turmoil, Sanders, Michelle Obama,... 31
- Dems' division, emails roil party on... 28
- Watch live at the Democratic National... 25
- In wake of email hack, Democratic chair... 23
- Trump says Russia should find Clinton's... 21