A U.S. sailor fatally shot two civilian Defense Department employees and wounded a third at Pearl Harbor Naval Shipyard in Hawaii on Wednesday before killing himself, military officials said.

Rear Adm. Robert Chadwick said the civilian shipyard worker who was wounded is stable. The gunman has been tentatively identified as an active duty sailor assigned to a submarine, he said.

"We have no indication yet whether they were targeted or if it was a random shooting," Chadwick said.

The shooting happened around 2:30 p.m. local time at Dry Dock 2 in the shipyard at Joint Base Pearl Harbor-Hickam Navy Region Hawaii, spokeswoman Lydia Robertson said. The shooting forced the base into lockdown, but the scene was secured.

One witness who did not give his name told NBC affiliate KHNL of Honolulu in a phone interview that he was at his desk and heard loud pops that he thought to be gunshots and looked out the window to see a person he thought was a shooter point a gun at his head and fire.

The identities of the gunman and the victims were not immediately released, pending notification of next of kin, Chadwick said. The survivor, a 36-year-old man, was in guarded condition, according to The Queen's Health Systems.

Chadwick said the gunman has been tentatively identified as being assigned to the USS Columbia submarine, which was at dry dock at the base for maintenance. He said the three people who were shot were men and were shipyard workers.

"Obviously our thoughts are with the families of the victims and everyone involved,” Chadwick said at a news conference.

Hannah Milne said over text messages that she had been inside a vehicle when the base was locked down. "There are still numerous emergency vehicles coming every 5-10 minutes," she said at the time.

White House principal deputy press secretary Hogan Gidley said that President Donald Trump had been briefed on the shooting and continues to monitor the situation.

Hawaii Gov. David Ige tweeted that the White House had reached out to offer assistance.

"I join in solidarity with the people of Hawai'i as we express our heartbreak over this tragedy and concern for those affected by the shooting," Ige said.

Base security and Navy investigative services were investigating the incident.

Chadwick said he did not know the type of weapon used. Bringing personal weapons on base is not authorized, he said.

The ships and submarines of the U.S. Pacific Flee are headquartered at Pearl Harbor. Kent Nishimura / AFP - Getty Images file

The shipyard repairs, maintains and modernizes the ships and submarines of the U.S. Pacific Fleet, which is headquartered at Pearl Harbor. The base is the home port for 10 destroyers and 15 submarines.

The naval shipyard is on base, and the Pearl Harbor National Memorial is off base about 1 1/2 miles away.

The anniversary of the 1941 Japanese attack on Pearl Harbor is Saturday. More than 2,400 members of the military and civilians died in that attack, which propelled the U.S. into World War II.