The two people killed were Department of Defence civilian employees, while a third civilian was wounded but "in stable condition at (an) area hospital," the official said.
A spokeswoman for the Joint Base Pearl Harbour-Hickam confirmed that a shooting had taken place but declined to give any further details.
"The incident occurred at approximately 2:30 pm. Due to the ongoing security incident, access/gates to #JBPHH are closed," the base said on Twitter.
NBC affiliate Hawaii News Now, citing a base spokesman, said at least three people had been wounded in the attack, which took place at Drydock 2 of the Pearl Harbor Naval Shipyard.
An unnamed witness told Hawaii News Now in an on-air interview that he had seen the gunman put a gun to his head and shoot himself. The gunman was wearing a US Navy uniform, the witness told the station.
Watch: United States' bloody history of mass shootings
Hawaii News Now earlier reported that two of the victims were in grave condition at local hospitals.
Joint Base Pearl Harbor-Hickam is a combined US Air Force and Navy Installation located 13 km from Honolulu.
The base was put on lockdown for about two hours after the shooting.
The incident comes three days before the anniversary of the December 7, 1941 attack on the naval base that led the United States to enter World War Two by declaring war on Japan.