The US president has repeatedly denounced the press as ‘the enemy of the American people’.

US President Donald Trump has reacted to a fatal shooting at a Maryland newspaper by saying journalists “should be free from the fear of being violently attacked”.

Mr Trump said the attack on the Capital Gazette, which left five dead and others injured, “shocked the conscience of our nation and filled our hearts with grief”.

The president has repeatedly denounced the press as “the enemy of the American people”.

“Journalists, like all Americans, should be free from the fear of being violently attacked while doing their job,” Mr Trump said.

Before going any further today, I want to address the horrific shooting that took place yesterday at the Capital Gazette newsroom in Annapolis, Maryland. This attack shocked the conscience of our Nation, and filled our hearts with grief… pic.twitter.com/LALXGhk04b — Donald J. Trump (@realDonaldTrump) June 29, 2018

He went on to tell the families of the victims: “There are no words to express our sorrow for your loss. Horrible, horrible event, horrible thing happened and you’re suffering.”

The alleged shooter, who had a history of harassing the paper’s journalists, has been charged on five counts of first-degree murder. It was the deadliest attack on journalists in US history.

The gunman had filed a defamation suit against the paper in 2012 that was thrown out as groundless, and he repeatedly targeted the paper’s staff members in profanity-laced tweets.

In his remarks, Mr Trump pledged his “eternal support” to those suffering losses and said his government “will not rest until we have done everything in our power to reduce violent crime and to protect innocent life”.

He did not mention the First Amendment in his statement, delivered at the top of an event celebrating the tax cuts he signed into law last year.

Journalists tell the stories of our communities, protect democracy, & often put their lives on the line just to do their jobs. Today’s attack in Annapolis is devastating. Our hearts go out to all the victims & their families. — Justin Trudeau (@JustinTrudeau) June 29, 2018

Canadian Prime Minister Justin Trudeau’s tweeted statement stood in contrast.

“Journalists tell the stories of our communities, protect democracy, & often put their lives on the line just to do their jobs,” Mr Trudeau wrote. “Today’s attack in Annapolis is devastating. Our hearts go out to all the victims & their families.”

Mr Trump has had a hostile relationship with the press since long before he took office, popularising the term “fake news” and repeatedly denouncing journalists as “the enemy of the American people”.

Last summer, he tweeted a doctored WWE professional wrestling video clip that depicted him tackling and pummelling an opponent whose head had been covered by a superimposed CNN logo. He added the hashtags “#FraudNewsCNN” and “#FNN.”

CNN responded at the time with a statement accusing the president of encouraging violence. “It is a sad day when the President of the United States encourages violence against reporters,” it said.

Strongly condemn the evil act of senseless violence in Annapolis, MD. A violent attack on innocent journalists doing their job is an attack on every American. Our prayers are with the victims and their friends and families. — Sarah Sanders (@PressSec) June 28, 2018

Asked on Thursday whether she had any concerns that the president’s constant criticism of the press might pose a danger, 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.”

Press Secretary Sarah Sanders added in a tweet: “Strongly condemn the evil act of senseless violence in Annapolis, MD. A violent attack on innocent journalists doing their job is an attack on every American. Our prayers are with the victims and their friends and families.”

Despite his hostile rhetoric, the president is an avid consumer of news and seems to enjoy his frequent interactions with reporters. He has also, at times, praised the press, telling a room of journalists at the annual Gridiron Dinner this year that “there are few professions that I respect more”.

“I want to thank the press for all you do to support and sustain our democracy. I mean that. I mean that. Some incredible people in the press … brilliant, powerful, smart, and fair people in the press. And I want to thank you,” he said then.