Staff at the Capital Gazette in Annapolis said the attacker, armed with a shotgun and smoke grenades, shot through a glass door into the newsroom.
US media have named a suspect held by police as Jarrod Ramos, who is reported to have unsuccessfully sued the newspaper group in 2012 for defamation.
Police have not confirmed a motive.
They said a white male suspect in his late 30s was taken into custody at the scene of the shooting and was being questioned.
Investigators were said to be looking into “violent” threats that had been made against the Capital Gazette via social media.
“This was a targeted attack on the Capital Gazette,” said William Krampf, deputy chief of Anne Arundel County Police. He added that the gunman “entered the building with a shotgun and looked for his victims as he walked through the lower level”.
County executive Steve Schuh told CNN that the suspect was hiding under a desk in the building when police officers arrived “within 60 seconds” of receiving news of the incident. He said there was “no exchange of fire”.
The Capital Gazette publishes several local newspapers, including a daily called The Capital, which has a history dating back to 1884. It is owned by the Baltimore Sun Media Group.
The Baltimore Sun reported that police gathered outside Mr Ramos’ house on Thursday after the attack. It said the alleged suspect has a “long-running feud” with The Capital over a 2011 report on a criminal harassment case against him.
The victims have been identified by police. They are:
- Wendi Winters, 65, reporter
- Rebecca Smith, 34, sales assistant
- Robert Hiaasen, 59, editor
- Gerald Fischman, 61, editorial writer
- John McNamara, 56, reporter and editor
Speaking to reporters, Mr Krampf said an item “we believed to be an explosive device” had been found at the premises and destroyed. He said it turned out to be a smoke bomb.
He added that more than 170 people had been escorted safely from the building, which houses other businesses.
Staff at the Capital Gazette’s titles were left reeling from the shooting, but vowed to put out an edition on Friday.
“There is nothing more terrifying than hearing multiple people get shot while you’re under your desk and then hear the gunman reload,” tweeted reporter Phil Davis.
Mr Davis described the shooting at the newspaper’s office in Annapolis, just east of Washington DC, as being “like a war zone”.
He said that people were still hiding under their desks when the gunman stopped shooting. “I don’t know why. I don’t know why he stopped,” he told the Baltimore Sun.
Chase Cook, a reporter, tweeted: “I can tell you this: We are putting out a damn paper tomorrow.”
President Donald Trump was briefed on the attack. He tweeted that his “thoughts and prayers” were with the victims and their families.
White House Press Secretary Sarah Sanders later condemned the attack on “innocent journalists doing their job”. (Courtesy BBC)