City Manager Dave Hansen said Sunday the suspect notified his superiors via email about his intention to quit his job Friday afternoon.
The suspect was identified as Dwayne Craddock, a longtime public utility employee.
Police Chief James Cervera said the gunman was a disgruntled worker who was killed by police in what he described as “long-term” shootout. A motive had not yet been determined.
City Manager Hansen said all but one of the murdered victims were Virginia Beach employees and one was a contractor.
Officials said at four others were wounded in the shooting.
Witnesses say the shooting took place at Building Two of the Virginia Beach municipal complex, which houses the city’s public works, public utilities and planning departments.
Cervera said one police officer was among those who was hit by gunfire but said the officer survived. The chief said the gunfight with the officers prevented the suspect from killing more victims.
He said the gunman used a .45-caliber pistol equipped with a “sound suppressor” device and “extended” ammunition magazines that he reloaded repeatedly during the attack.
The killings were the latest in a growing list of mass shootings in the U.S. It was the deadliest mass shooting since November when a gunman killed 12 people at a bar in Thousand Oaks, California before killing himself. A policeman also died of gunshot wounds after responding to calls for help in that instance.