The official said surveillance video of the shooting was being reviewed, and that scores of investigators were interviewing hundreds of witnesses.
Alexis may have gained entry into the Navy Yard by using someone else's identification card, said a federal law enforcement official who spoke to the Associated Press on condition of anonymity because the official was not authorized to speak publicly.
Terrie Durham, an executive assistant at Naval Sea Systems Command, said a fire alarm sounded and she was trying to leave with a group of people when they encountered a shooter.
"We couldn't see his face, but we could see him with the rifle," Durham said. "He raised and aimed at us and fired. And he hit high on the wall."
Rick Mason, a program management analyst, said a gunman began shooting from a fourth-floor overlook in the hallway outside his office. He said the gunman was aiming down at people in the building's cafeteria on the first floor.
Patricia Ward, a logistics management specialist, said she was in the cafeteria. "I heard three shots -- pow, pow, pow. Thirty seconds later I heard four more shots."
Then panic, as people tried to get out of the cafeteria. "A lot of people were just panicking. There were no screams or anything because we were in shock."
Dave Sarr, an environmental engineer, was walking down a nearby street when he saw people running from the Navy Yard. Sarr has seen an evacuation drill a few days earlier at the Navy Yard. "At first I thought it was another drill," Sarr said. "Then I saw an officer with his weapon drawn."
President Obama made a brief statement, describing the victims as "patriots" and promising a thorough investigation. "I made it clear to my team that I want the investigation to be seamless," Obama said.
The first news broke with the Navy reporting on its Twitter feed that there was an "active shooter" at Building 197 at the Navy Yard, and that three shots had been fired at 8:20 a.m. ET. The Navy later reported deaths and injuries, but details remained fluid.
Flights at nearby Washington Reagan National Airport were disrupted, with all departures temporarily halted at the airport.
At MedStar Washington Hospital Center, chief medical officer Janis Orlowski said the hospital was treating three victims -- a male D.C. police officer and two women.
She said the police officer had multiple gunshot wounds to his legs and was in surgery. One woman was shot in the shoulder, and the other in the head and hand. All are expected to survive, she said.
The Navy Yard is located on the banks of the Anacostia River, a few blocks from the Nationals baseball stadium. It's in an urban area where the development of new parks, shops and apartments has been ongoing.
The Washington Nationals baseball team canceled Monday night's game against the Atlanta Braves. A parking lot at Nationals Stadium was being used as a site for families seeking to reunite with loved ones who work at the Navy Yard.
The city had not decided how long the area by the Navy Yard, including the baseball stadium, would remain closed to the public, said Keith St. Clair, communications director for the deputy mayor for public safety and justice.
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. It builds, buys and maintains the Navy's ships and submarines and their combat systems.
NAVSEA headquarters' security requires guests to pass through turnstiles that are watched by security guards before entering. Visitors must also turn in their phones and other electronic recording devices upon entry.
Capt. Michael Graham, who works at NAVSEA, was running late this morning and by the time he arrived at work the base was already in a lockdown.
Graham said he had never seen a shelter-in-place drill in his five years at NAVSEA.
"I've never seen a shelter-in-place, I've seen the normal fire drills things like that, but never a shelter-in-place drill," said Graham. "Normally the drills you have are to get out of the building."
Marine Barracks Washington also put its base on a partial lockdown, only allowing Marines to leave if they were on official business, said Capt. Jack Norton, a base spokesman. A small contingent from Marine Barracks Washington's Guard Company serves at the Navy Yard, Norton said.
Contributing: Marisol Bello; Anne Willette, Kevin Johnson, Jim Michaels, Will Cummings, USA TODAY; Navy Times; WUSA TV; Associated Press