A Maryland man charged with rampaging through a newsroom in Annapolis with a pump-action shotgun and killing five people has been denied bail after one of the deadliest attacks on journalists in US history.

Jarrod Ramos, a 38-year-old man from Laurel, is not cooperating with investigators, authorities said, and did not speak as he appeared by video link from a detention facility for a brief court hearing at Anne Arundel County criminal court.

Mr Ramos had a longstanding grudge against the newspaper that was targeted and unsuccessfully sued it for defamation in 2012 over an article that reported how he harassed a former high school classmate, court records showed.

He is accused of entering the Capital Gazette office on Thursday afternoon and opening fire through a glass door, hunting for victims and spraying the newsroom with gunfire as reporters hid under their desks and begged for help on social media.

We need your consent to load this rte-player contentWe use rte-player to manage extra content that can set cookies on your device and collect data about your activity. Please review their details and accept them to load the content.Manage Preferences

Prosecutors said he barricaded a back door to stop people from fleeing.

"The fellow was there to kill as many people as he could," Anne Arundel County Police Chief Timothy Altomare told a news conference, adding that the suspect was identified using facial-recognition technology.

Mr Altomare said evidence found at the suspect's home showed he planned the attack, and that the pump-action 12 gauge shotgun used by the shooter was legally purchased about a year ago.

US President Donald Trump, who has frequently criticised the media, lamented the shooting.

"This attack shocked the conscience of our nation and filled our hearts with grief.

"Journalists, like all Americans, should be free from the fear of being violently attacked while doing their job," Mr Trump said before a speech to celebrate the tax overhaul law.


Victims of the Maryland shooting


Rob Hiaasen, 59, Wendi Winters, 65, Rebecca Smith, 34,Gerald Fischman, 61, and John McNamara were shot and killed.

All were journalists except for Ms Smith who was a sales assistant, police said.

Mr Hiaasen was the brother of best-selling author Carl Hiaasen.

The Capital newspaper, part of the Gazette group, published an edition today with photographs of each of the victims and a headline "5 shot dead at The Capital" on its front page.

The newspaper's editors left the editorial page blank with a note saying that they were speechless.

Chase Cook (R) and photographer Joshua McKerrow (L) work while awaiting news from their colleagues 

Photographs that were widely shared on social media showed newspaper staffers working on laptops in a parking garage to produce Friday's edition while they waited to learn the fate of colleagues after the shooting.

Annapolis Mayor Gavin Buckley said he was so proud of the journalists who had "soldiered on."

"These guys, they don't make a lot of money. They do journalism because they love what they do. And they got a newspaper out today," Mr Buckley said.

A vigil for the victims is planned for tonight. Maryland Governor Larry Hogan ordered state flags to be lowered to half-staff.

Ramos brought a defamation lawsuit in 2012 against Eric Hartley, a former staff writer and columnist with Capital Gazette, and Thomas Marquardt, then its editor and publisher, a court filing showed.

Neither Mr Hartley nor Mr Marquardt is still employed by the paper or were at its office on Thursday.

An article by Mr Hartley had contended that Ramos had harassed a woman on Facebook and that he had pleaded guilty to criminal harassment, according to a legal document.

The court agreed the article was accurate and based on public records, the document showed.

In 2015 Maryland's second-highest court upheld the ruling, rejecting Ramos's suit.

Ramos tweeted at the time that he had set up a Twitter account to defend himself, and wrote in his biographical notes that he was suing people in Anne Arundel County and "making corpses of corrupt careers and corporate entities."

According to a WBAL-TV reporter who said she spoke with the woman who was harassed, Ramos became "fixated" with her for no apparent reason, causing her to move three times, change her name, and sleep with a gun.

Phil Davis, a Capital Gazette crime reporter, recounted how he was hiding under his desk along with other newspaper employees when the shooter stopped firing, the Capital Gazette reported on its website.

The newsroom looked "like a war zone," he told the Baltimore Sun. "I don't know why he stopped."

Authorities responded to the scene within a minute of the shooting, and Ramos was arrested while also hiding under a desk with the shotgun on the floor nearby, police said.

He will face either a preliminary court hearing or grand jury indictment within the next 30 days.

Capital Gazette runs several newspapers out of its Annapolis office. They include one of the oldest newspapers in the United States, The Gazette, which traces its origins back to 1727.