A longtime city employee opened fire at a municipal building in Virginia Beach, Va., on Friday, killing 12 people and sending terrified co-workers scrambling for cover before police shot and killed him, authorities said.

Four other people were wounded in the shooting, including a police officer whose bulletproof vest saved his life, said Virginia Beach Police Chief James Cervera. The city's visibly shaken mayor, Bobby Dyer, called it "the most devastating day in the history of Virginia Beach."

The shooting happened shortly after 4 p.m. local time when the veteran employee of the Public Utilities Department entered a building in the city's Municipal Center, and "immediately began to indiscriminately fire upon all of the victims," Cervera said. He did not release the suspect's name.

Police entered the building and got out as many employees as they could, then exchanged fire with the gunman, who was killed, the chief said.

Police initially said the gunman shot and killed 11 people. Cervera later said one more died on the way to the hospital.

The shooting sent shock waves through Virginia Beach, the state's largest city and a popular vacation spot in southeastern Virginia.

The building where the attack took place is in a suburban complex kilometres away from the high-rise hotels along the beach and the downtown business area.

Virginia Gov. Ralph Northam said in a statement he was devastated by the "unspeakable, senseless violence," and is offering the state's full support to survivors and relatives of the victims.

"That they should be taken in this manner is the worst kind of tragedy," the governor said during a Friday night news conference.

The White House said U.S. President Donald Trump had been briefed and was monitoring the situation.

'Nothing like this happens in Virginia Beach'

Megan Banton, an administrative assistant who works in the building where the shooting happened, said she heard gunshots, called 911 and barricaded a door.

"We tried to do everything we could to keep everybody safe," she said. "We were all just terrified. It felt like it wasn't real, like we were in a dream. You are just terrified because all you can hear is the gunshots."

At a nearby middle school, friends and relatives were reuniting with loved ones who were in the building when the shooting happened. They included Paul Swain, 50, who said he saw his fiancee from across the parking lot, clearly in an agitated state.

Emergency vehicles respond to the shooting Friday. (Kaitlin McKeown/The Virginian-Pilot via AP)

"I think she knew some of the people," he said.

Cheryl Benn, 65, waited outside the middle school while her husband, David Benn, a traffic engineer with the city who was in the building where the shooting happened, gave a written statement of what he saw to detectives.

She said her husband initially called her from a barricaded room and said it sounded as if someone had been working with a nail gun. Then he saw the bodies.

"This is unbelievable for Virginia Beach," Benn said. "Nothing like this happens in Virginia Beach. By and large, it's a pretty calm and peaceful place to live."