Navy security forces then killed the suspect, who was authorized to be on Naval Station Norfolk in Virginia and did not bring his own weapon on base, according to Capt Robert Clark, the base's commanding officer.
The identities of the civilian and the sailor who were killed have not been released.
No other injuries were reported from the encounter, which occurred Monday about 11:20 pm on the USS Mahan, a guided-missile. It wasn't immediately clear why the civilian approached the ship or if he ever had access to it previously.
The Navy said the civilian was coming toward the ship's quarterdeck, which is traditionally the ceremonial entry point aboard a ship, when the struggled ensued and the civilian was able to disarm the Petty Officer of the Watch.
More From This Section
Clark said the identification found with the civilian indicates it is unlikely he was a military dependent authorised to be on base for that reason. He said the civilian was found with a TWIC card. According to the Navy's Military Sealift Command, a TWIC card is a transportation worker's credential card and is necessary to apply for any jobs with the command.
The base was briefly on lockdown following the shooting, but traffic was back to normal early yesterday morning.
The Navy will release both men's names after their families are notified, said Naval Station Norfolk spokeswoman Terri Davis.
Aside from the pier where the Mahan was docked, operations had returned to normal at the base, with counselors available, the Navy said in a statement.
The shooting on the Mahan comes about a month after the Navy held anti-terrorism and force protection exercises on bases around the US, including an active-shooter drill at the Norfolk station.
To get on the base, civilians must be escorted or have identification that allows them to be there. Authorized civilians can include Department of Defense employees, contractors and military family members.