Media playback is unsupported on your device Media caption Police describe how the shooting at the newspaper office ended

A gunman has opened fire at a local newspaper office in Maryland, killing five people and injuring others in what police said was a "targeted attack".

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. He 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.

Image copyright Reuters Image caption Armed officers escorted more than 170 people from the building in Annapolis

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

Author and Miami Herald columnist Carl Hiaasen paid tribute to his brother, who was killed in the shooting, calling him "one of the most gentle and funny people I've ever known".

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.

'War zone'

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."

Image copyright AFP Image caption Capital Gazette reporters were pictured working on the next day's newspaper from the car park

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".

The New York City Police Department (NYPD) said it had deployed counterterrorism teams to media organisations in and around New York City as a precaution.

Read more about US gun violence

Media playback is unsupported on your device Media caption After the Las Vegas attack in October 2017 the BBC looked at how US mass shootings are getting worse

Another staff member at the Capital Gazette, Selene San Felice, told CNN that her first reaction to the shooting was to lie down under her desk, adding that she attempted to exit through a rear door but it was locked.

Reporter Danielle Ohl said the newsroom was quite small, with "about 20 news staffers" and several advertising staff. "We are close. We are family. I am devastated," she said.

Jimmy DeButts, the editor at the Capital Gazette, tweeted that he was "heartbroken" following the incident.

Federal agencies, including the FBI and the Bureau of Alcohol, Tobacco, Firearms and Explosives, were involved in the response to the attack.

Maryland governor Larry Hogan said on Twitter he was "absolutely devastated" and was in contact with authorities.

Democratic senator Chris Van Hollen responded to Mr Davis on Twitter, saying "journalists shouldn't have to fend off bullets in the newsroom".