WASHINGTON — A former Navy reservist killed at least 12 people on Monday in a mass shooting at a secure military facility that led the authorities to lock down part of the nation’s capital — even after the gunman was killed — in a hunt for two other armed men spotted by video cameras, officials said.

But by Monday evening, the federal authorities said they believed the shooting was the act of a lone gunman, identified as Aaron Alexis, 34, who was working for a military subcontractor.

The chaos at the facility, the Washington Navy Yard, started just after 8 a.m. Civilian employees described a scene of confusion as shots erupted through the hallways of the Naval Sea Systems Command headquarters, on the banks of the Anacostia River a few miles from the White House and about a half-mile from the Capitol.

“I heard three gunshots, pow, pow, pow, straight in a row,” said Patricia Ward, a logistics management specialist from Woodbridge, Va., who was in the cafeteria on the first floor when the shooting started. “About three seconds later, there were four more gunshots, and all of the people in the cafeteria were panicking, trying to figure out which way we were going to run out.”

Police officers who swarmed the military facility exchanged fire with Mr. Alexis, 34, a former naval reservist in Fort Worth. Police officers shot Mr. Alexis to death, law enforcement officials said, but not before a dozen people were killed and several others, including a city police officer, were wounded and taken to local hospitals.

Officials said Mr. Alexis drove a rental car to the base and entered using his access as a contractor and shot an officer and one other person outside Building 197, the Sea Systems Command headquarters. Inside, Mr. Alexis made his way to a floor overlooking an atrium and took aim at employees eating breakfast below.

“He was shooting down from above the people,” one law enforcement official said. “That is where he does most of his damage.”

The names of seven of the victims were released late Monday: Michael Arnold, 59; Sylvia Frasier, 53; Kathy Gaarde, 62; John Roger Johnson, 73; Frank Kohler, 50; Kenneth Bernard Proctor, 46; and Vishnu Pandit, 61. Officials said names of the other victims would be released after their families had been contacted. All of the victims were believed to be civilians or contractors. No active duty military personnel were killed, said Chief Cathy L. Lanier of Washington.