One of the gunmen was dead, and police were searching for two other men believed to have joined in the attack at the Washington Navy Yard. The suspects were reportedly dressed in military-style clothing, including one who had on a beret.
In all, more than a dozen people were shot, at least half of them fatally. It was not immediately clear whether that number included the dead gunman.
The building that was targeted was the military's headquarters for Naval Sea Systems Command, which buys, builds and maintains ships, submarines and combat systems. About 3,000 people work at the headquarters, many of them civilians.
Witnesses described a gunman opening fire from a fourth-floor overlook, aiming down on people in the first-floor cafeteria. Others said a gunman fired at them in a third-floor hallway.
It was not clear whether the witnesses on different floors were describing the same gunman.
As emergency vehicles and law enforcement officers flooded streets around the complex, a helicopter hovered overhead, nearby schools were locked down and airplanes at nearby Reagan National Airport were briefly grounded so they would not interfere with law-enforcement choppers. Less than 2 miles away, security was beefed up at the Capitol and other federal buildings, but officials said there was no known threat.
President Barack Obama mourned yet another mass shooting in the U.S. that he said took the lives of American patriots. Obama promised to make sure "whoever carried out this cowardly act is held responsible."
Two Navy officials confirmed at least six people had died. The officials spoke on condition of anonymity because they were not authorized to talk about the situation publicly.
Todd Brundidge, an executive assistant with Navy Sea Systems Command, said he and other co-workers encountered a gunman in a long hallway on the third floor. The gunman was wearing all blue, he said.
"He just turned and started firing," Brundidge said.
Terrie Durham, an executive assistant with the same agency, said she also saw the gunman firing toward her and Brundidge.
"He aimed high and missed," she said. "He said nothing. As soon as I realized he was shooting, we just said, 'Get out of the building.'"
Rick Mason, a civilian program-management analyst for the Navy, said a gunman was shooting from the overlook in the hallway outside his office.
Shortly after the gunfire, Mason said, someone on an overhead speaker told workers to seek shelter and later to head for the gates at the complex.
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 told reporters several blocks away from the Navy Yard.
Ward said security officers started directing people out of the building with guns drawn.
One person died at George Washington University Hospital of a single gunshot wound to the left temple, said Dr. Babak Sarani, director of trauma and acute care surgery. A police officer and two civilian women were in critical condition at Washington Hospital Center, said Janis Orlowski, the hospital's chief operating officer.
Orlowski said the police officer was in the operating room with gunshot wounds to the legs. One woman had a gunshot wound to the shoulder. The other had gunshot wounds to the head and hand.
Naval Sea Systems Command is the largest of the Navy's five system commands and accounts for a quarter of the Navy's entire budget. Only security personnel were allowed to be armed on the campus.
The Navy Yard has three gates, according to its website. One is open around the clock and must be used by visitors. A second gate is only for military and civilian Defense Department employees. The other gate is for bus traffic.
The Navy Yard is part of a fast-growing neighborhood on the banks of the Anacostia River in southeast Washington, just blocks from the Nationals Park baseball stadium.