A US sailor shot dead two workers before taking his own life at the Pearl Harbor military base near Honolulu in Hawaii on Wednesday.
Officials say the gunman also injured a third worker before he killed himself.
The incident prompted a lockdown at Joint Base Pearl Harbor-Hickam, which is on the Hawaiian island of Oahu.
The shooting was reported at about 14:30 (00:30 GMT) local time. The identities of those involved in the shooting have not yet been confirmed.
All three victims were civilian defence department employees and the survivor is in stable condition, officials said.
Rear Admiral Robb Chadwick, speaking at a press conference, said it was unclear if the victims were targeted or shot at random.
He said the gunman has tentatively been identified as an active duty serviceman assigned to the USS Columbia.
The submarine is currently undergoing maintenance at the base, US media reports.
“Obviously our thoughts are with the families of the victims and everyone involved,” Rear Adm Chadwick added.
Rear Admiral Robert Chadwick said the gunman died from “an apparent self-inflicted gunshot wound”
The shooting prompted a lockdown at the military base, which is home to US navy and air force personnel.
Both base security and the Naval Criminal Investigative Service are investigating the shooting, a spokesman said.
Hawaii’s governor, David Ige, responded to the shooting in a tweet and confirmed the White House had offered federal assistance.
The shooting comes just three days before the 78th anniversary of a Japanese attack on Pearl Habor naval station, which left more than 2,300 Americans dead.
The surprise attack, on 7 December 1941, prompted the US to declare war on Japan and enter World War Two.