Aaron Alexis, 34, of Fort Worth, Texas, died in a gun battle with police during the rampage at Washington Navy Yard.
Eight others were injured in the attack, which began at around 8:20 local time on Monday.
President Barack Obama ordered flags be lowered to half mast at the White House and on Capitol Hill.
He said he mourned “yet another mass shooting” and condemned the “cowardly act”.
No motive is known for the attack, whose dozen victims ranged in age from 46 to 73, said the authorities.
Police initially responded to reports of two other armed suspects, but after exhaustive searches Washington Police Chief Cathy Lanier said on Monday night they were all but certain that Aaron Alexis was the only gunman.
Witnesses said suspect Aaron Alexis sprayed bullets in a hallway and fired from a balcony down on to workers in an atrium at the heavily secured installation in the US capital.
Aaron Alexis was reportedly armed with an AR-15 semi-automatic rifle, a shotgun and a handgun that he took from a police officer at the scene.
Chief Cathy Lanier told reporters that the attacker “was engaged in shooting with police officers” when he died.
“There is no question he would have kept shooting,” she added.
Valerie Parlave of the FBI said that the suspect, who was employed by a subcontractor that was working on a US Navy intranet network, had a valid pass to enter Washington Navy Yard.
Aaron Alexis was formerly a petty officer 3rd class who served full-time in the naval reserve from 2007-11, said the US Navy.
It was not immediately clear why he left the military, but unnamed military officers told US media there had been a series of misconduct issues during his service.
According to media reports, Aaron Alexis was a Buddhist convert who had had two previous gun-related brushes with the law.
In 2004 Aaron Alexis was arrested in Seattle for shooting a construction worker’s car tyres, in what he described as an enraged “black-out”.
And he was questioned by Fort Worth police in 2010 after firing his gun through the floor of an upstairs apartment. He said it was an accidental discharge.
In addition to those killed in Monday’s rampage, one police officer was shot in the legs, a female civilian was shot in the head and hand, and another woman was treated for a shoulder wound.
All three were expected to recover, said Washington Hospital Center officials.
Five others required medical treatment, mostly for minor injuries, said Washington DC Mayor Vincent Gray.
As news of the shooting emerged, emergency vehicles and police surrounded the complex, while helicopters hovered overhead.
The US Senate buildings and six nearby schools were temporarily placed on lockdown as a precaution, while flight departures were briefly suspended at Reagan National Airport.
Patricia Ward, who works at Washington Navy Yard, said she had heard three shots, a pause, and then four more.
“Everybody was panicking and trying to decide which way to get out,” she told reporters.
The Washington Nationals baseball team called off their game against the Atlanta Braves on Monday night at Nationals Park, not far from Navy Yard.
Monday’s mass shooting occurred at a building that serves as the headquarters for the Naval Sea Systems Command, which builds and maintains ships and submarines for the Navy.
Washington Navy Yard is the US Navy’s oldest shore installation, first opened in the early 19th Century, according to the Navy.
Q3vhGXQJ9bYQuincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…
Misleading allegations, rumours and outright lies about voting and fraud are flooding online spaces in…
At least 158 people have died in Spain's worst flooding disaster in generations. On October…
Google has been fined two undecillion (a two followed by 36 zeroes) roubles by a…
Embarking on a home remodel is an exciting journey, promising enhanced comfort, increased property value,…
The US presidential candidates continued to campaign across key swing states on October 20. Footage…