He was named by the FBI as Aaron Alexis of Fort Worth, Texas, who had been discharged from the Navy Reserve in 2011 after a series of "misconduct issues".
Alexis was among the dead and authorities said they were searching for another possible gunman wearing military-style clothing.
Another official said Alexis had been a civilian contractor for the US Navy in the information technology area but it was unclear whether he still worked for at the time of today's shooting.
Earlier, officials said they were looking for two men, but then said police had established one of them was not a suspect in the shooting, which began at about 8.30am EDT (1230 GMT).
The Washington DC mayor and the police chief reported 12 fatalities and at least 13 wounded at the Naval Sea Systems Command, one of five such commands where civilians, military personnel and contractors build, buys and maintain Navy ships and submarines. About 3,000 people work there.
"We have no indication of motive at this time," said Washington D.C. police chief Cathy Lanier.
Patricia Ward, who works at the Navy Yard, said she heard three shots "pow, pow, pow" and then four more shots after a pause.
"Everybody was panicking and trying to decide which way to get out," Ward said.
Security guards told people to "run, run, run," Ward said.
Reached by telephone, Aaron Alexis' father, Algernon Alexis, seemed stunned by the news his son may have been involved.
"This comes as a complete shock," he said and then asked how he could reach authorities leading the investigation. He said his son was former military and now studying while working in a computer-related job for a private company.
President Barack Obama was briefed on the shooting and then talked about it at the start of a speech on the US economy.
"We are confronting yet another mass shooting, and today it happened at another military installation, in our nation's capital," said Obama, who vowed to enact "sensible" gun control measures after a gunman shot dead 20 school children and six adults at an elementary school in Connecticut last December.
"They know the dangers of serving abroad, but today they face the unimaginable violence that they wouldn't have expected here at home," Obama said.
The Washington shooting happened less than three weeks after US Army psychiatrist Major Nidal Hasan was sentenced to death for murdering 13 people in 2009 at Fort Hood, Texas, where he gunned down unarmed soldiers in what he later called retaliation for US wars in Muslim countries.
Among the injured in today’s shooting was a District of Columbia police officer, who was in stable condition in surgery, and one other law enforcement officer, officials said.
Washington Hospital Center said it was treating three gunshot victims, who were in critical condition, and was expecting more to arrive.
"We had a few additional folks who were injured, they were not fatally injured," Lanier said.
At George Washington University, a man in his 60s died of a single gunshot wound to his head, said Babak Sarani, head of trauma surgery.
The man was shot in his left temple and the injury "was not survivable by any stretch," Sarani told reporters, adding he was unsure what type of weapon was used or whether the bullet had exited the victim's body.
The shooting revealed a potentially serious security breach.
The command where the shooting takes place requires two separate identification badges, one to get on the base and another to access the building, according to a source who works at the Navy Yard and requested anonymity. Military personnel are generally banned from carrying weapons on military installations but most people with proper credentials are not routinely checked for firearms.
"It will be interesting to see as this develops who the shooter is, how he got in," said Navy Commander Tim Jirus, who was in charge of evacuating the Sea Command building. "Right now a lot of people are wondering just how safe the building is or just how safe the office environment is."
"You just want to know why," said David Reyes, a tech sergeant stationed at Andrews Air Force Base who rushed to the Navy Yard when he received a text message from his wife, who works there.
Dozens of police and emergency vehicles surrounded the complex in southeast Washington, which is about 1.6km south of the US Capitol and 5km from the White House. Helicopters circled the headquarters with some touching down on the building's roof.
The Federal Aviation Administration said it briefly suspended departures at Reagan National Airport. The District of Columbia Public Schools put six schools and an administration building on lockdown as a precaution. The Washington Nationals baseball team postponed their game against the Atlanta Braves scheduled for Monday night at nearby Nationals Park.