"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.
- Jailed, some mentally ill inmates land in...
- US, Arab allies hit IS strongholds in Syria,...
- International tax competitiveness report: See...
- Where do we draw the line on spanking?
- Police say rifle carried by ambush suspect found
- Obama scores coalition victory with Arab strikes
- Islamic State group calls for attacking...
- Private actions are company business
- Obama scores coalition victory with... 20
- Where do we draw the line on spanking? 16
- Islamic State group calls for attacking... 14
- Jailed, some mentally ill inmates land... 11
- Thousands march in NYC, around globe... 10
- How much America wants to be taxed 10
- Iranian youth behind 'Happy' video... 9
- Security breached: Intruder gets into... 9