In the hours after five people were killed in a U.S. newsroom shooting Thursday, leaders Donald Trump and Justin Trudeau struck starkly different tones in their public responses to the tragedy.

"Journalists tell the stories of our communities, protect democracy, (and) often put their lives on the line just to do their jobs," Canadian Prime Minister Trudeau wrote in a Twitter post overnight, adding the attack on the Capital Gazette in Annapolis, Maryland was "devastating" and extending condolences to victims and families.

In his Twitter post Thursday, U.S. President Trump also extended his "thoughts and prayers" to "the victims and their families," and thanked first responders.

Trump's tweet came moments after he walked past reporters Thursday without answering their questions, as they asked, "Any words about the dead in Annapolis?" and "Can you react to the shooting in Annapolis?"

In the footage, one reporter can be heard asking whether the U.S. president will continue to refer to reporters as enemies of the people. Some viewed the president's failure to respond as a "shock," but one in keeping with his documented antipathy toward the press; Trump has called the "fake news media" the "enemy of the American people."

Journalism and freedom of speech are protected in free and democratic societies, serving as a watchdog to hold the powerful to account and keep the public informed.

Outside the White House Thursday, Trump did not respond to reporters' questions about the Maryland shooting. Video posted on Facebook by NowThis Politics

Staff hid under desks Thursday when the shooting began. One intern, Anthony Messenger, tweeted a call for help as the shooter actively began his attack.

Two other people were also injured.

Jarrod Warren Ramos has been charged with five counts of first-degree murder in the deaths of four journalists and one sales assistant. According to reports, the 38-year-old had a long history of harassing those who worked at the newspaper.

One day after the tragedy, Trump appeared to show more empathy for the survivors and victims, noting that journalists, like all Americans, shouldn't be working in fear.

“I’d like to to address the horrific shooting that took place yesterday at Capital Gazette newsroom in Annapolis, Maryland," Trump said at the White House. "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.

"To the families of the victims, there are no words to express our sorrow for your loss. Horrible, horrible event — horrible thing happened. When you’re suffering, we pledge our eternal support. This suffering is so great. I’ve seen some of the people — so great. My government will not rest until we have done everything in our power to reduce violent crime and to protect innocent life. We will not ever leave your side. So, our warmest, best wishes and regrets. Horrific horrible thing.”

Prime Minister Justin Trudeau and leaders of Canada's opposition parties address members of the Canadian Parliamentary Press Gallery at their annual dinner in Gatineau, Que. on May 26, 2018. National Observer Facebook video

This wasn't the first time Trudeau came out strongly defending a free press. In May, following an incident involving masked far-right extremists who stormed the Montreal newsroom of Vice News to protest coverage, Trudeau noted that journalism was an important foundation of Canadian society.

"Journalists from Vice were harassed and intimidated by a far-right group in Montreal, here in Canada, and that's unacceptable," he said to applause from journalists at the annual Canadian parliamentary press gallery dinner on May 26.

A 34-year old man is facing charges of breaking an entering, mischief, criminal harassment and intimidation in connection with the Montreal incident at the Vice newsroom on May 23, The Canadian Press reported on June 19.

"You have a pretty powerful responsibility, and as much as you guys give me a hard time, I wouldn't have it any other way," Trudeau said at the press gallery dinner in May. "So please, keep asking the tough questions and keep us engaged in the essential debates that are shaping our society. For all you do, tonight, tomorrow and always, thank you."

Editor's note: This article was updated on June 29, 2018 at 2:25 p.m. ET with new comments made by Donald Trump.

Keep reading