Police said the suspect was a white man in his late 30s whose shotgun rampage at The Capital Gazette followed social media threats directed at the newspaper. A law enforcement official said the suspect has been identified as Jarrod W. Ramos. The official was not authorized to discuss the ongoing investigation by name and spoke on condition of anonymity.
RELATED: What we know about the Capital Gazette shooting suspect
Authorities said the gunman entered the building in a targeted attack and "looked for his victims." He had smoke grenades and fired a shotgun at his victims, according to Anne Arundel County Acting Police Chief William Krampf.
"This person was prepared today to come in, this person was prepared to shoot people. His intent was to cause harm," Krampf said.
The victims have been identified as special publications editor Wendi Winters, writer John McNamara, editorial page editor Gerald Fischman, sales assistant Rebecca Smith, and assistant editor and columnist Rob Hiaasen.
Krampf said the gunman was a Maryland resident and search warrants were being sought for his home.
Phil Davis, a reporter who covers courts and crime for the paper, tweeted that the gunman shot out the glass door to the office and fired into the newsroom, sending people scrambling for cover under desks.
"A single shooter shot multiple people at my office, some of whom are dead," he wrote. Davis added: "There is nothing more terrifying than hearing multiple people get shot while you're under your desk and then hear the gunman reload."
A single shooter shot multiple people at my office, some of whom are dead.— Phil Davis (@PhilDavis_CG) June 28, 2018
There is nothing more terrifying than hearing multiple people get shot while you're under your desk and then hear the gunman reload— Phil Davis (@PhilDavis_CG) June 28, 2018
The attacker had mutilated his fingers in an apparent attempt to make it harder to identify him, according to a law enforcement official who was not authorized to discuss the investigation and spoke on condition of anonymity. Another official who also spoke on condition of anonymity said investigators identified the man using facial recognition technology.
The shooting - which came amid months of verbal and online attacks on the "fake news media" from politicians and others from President Donald Trump on down- prompted New York City police to immediately tighten security at news organizations in the nation's media capital.
At the White House, spokeswoman Lindsay Walters said: "There is no room for violence, and we stick by that. Violence is never tolerated in any form, no matter whom it is against."
RELATED: Milo Yiannopoulos says he was joking about 'gunning down journalists'
Authorities said the suspect was undergoing questioning by detectives.
"The shooter has not been very forthcoming, so we don't have any information yet on motive," Anne Arundel County Executive Steve Schuh said. "To my knowledge, there was no verbal aspect to the incident where he declared his motives or anything else, so at this point we just don't know."
Krampf confirmed five deaths and said two people had superficial wounds. Authorities had said earlier that several people were gravely wounded.
Police spokesman Lt. Ryan Frashure said officers raced to the scene, arriving in 60 seconds, and took the gunman into custody without an exchange of gunfire.
About 170 people in all were evacuated from the building as a multitude of police cars and other emergency vehicles converged on the scene. People could be seen leaving the building with their hands up.
The newspaper is part of Capital Gazette Communications, which also publishes the Maryland Gazette and CapitalGazette.com.
In an interview with The Capital Gazette's online site, Davis said it "was like a war zone" inside the newspaper's offices - a situation that would be "hard to describe for a while."
"I'm a police reporter. I write about this stuff - not necessarily to this extent, but shootings and death - all the time," he said. "But as much as I'm going to try to articulate how traumatizing it is to be hiding under your desk, you don't know until you're there and you feel helpless."
Davis told the paper he and others were still hiding under their desks when the gunman stopped firing.
"I don't know why. I don't know why he stopped," he said.
Reporter Selene San Felice told the CNN broadcast outlet she was at her desk when she heard the shooting and ran with some others to a back door only to find it locked. She said she saw a colleague steps away as he was shot but didn't get a view of the shooter as she sought to hide.
"I heard footsteps a couple of times ... I was breathing really loud and was trying not to, but I couldn't be quiet," she added. Having gone to school in Florida, she recalled accounts of a gunman's June 2016 mass shooting attack on Orlando's gay nightclub Pulse and how terrified people crouching inside had texted loved ones. Dozens were killed there.
"And there I was sitting under a desk, texting my parents and telling them I loved them," she said.
Annapolis Mayor Gavin Buckley said the community is grieving the attack on their community paper.
"These are the guys that come to city council meetings, have to listen to boring politicians and sit there," Buckley said. "They don't make a lot of money It's just immoral that their lives should be in danger."
New York police sent counterterrorism teams to news organizations around the city in a move authorities said was a precaution, not prompted by any specific threat. Police could be seen outside The New York Times, ABC News and Fox News early in the evening.
Associated Press writers Eric Tucker in Washington and Michael Balsamo in Los Angeles contributed to this story.