He then began "systematically hunting and killing" people with a shotgun he hid when he entered the building in downtown Annapolis, federal prosecutor Wes Adams of Arundel County said Friday.
The Thursday attack left five people dead: Gerald Fischman, 61; Rob Hiaasen, 59; John McNamara, 56; Rebecca Smith, 34; and Wendi Winters, 65. Two other employees were injured while filming and released from hospital
Ramos allegedly used a 12-gauge shotgun and carried smoke grenades during the attack.
His motive remains unclear because he did not cooperate with investigators, but Anne Arundel police chief Timothy Altomare described it as a "targeted attack."
He shot people trying to escape
The first shots came through the front door and sent the staff to the back door. Ramos shot at least one victim trying to escape through the barricaded door, Adams said.
He paced the newsroom and was constantly shooting people, police spokesman Phil Davis said.
When the police arrived, they found Ramos hidden under a desk. He was charged with five counts of murder in the first instance, according to court records. A judge ordered him to detain him without bail.
"We are heartbroken, devastated, our colleagues and friends are gone, no matter how deep our loss is compared to the suffering of our friends' families," said Capital Editor Rick Hutzell in the front page of the newspaper on Friday.
The opinion page in the Friday papers was mostly left blank with a short message: "Today we are speechless." This page is intentionally released today to commemorate the victims of Thursday's shooting in our office. " It lists the names of the five victims.
History of hostility to the newspaper
For years, the suspect had voiced his hostility to the paper in a lawsuit and on social media.
Under the title "Jarrod wants to be your friend" describes the story of the writer Eric Hartley Ramos repeatedly contacted a former high school classmate via Facebook, according to court documents.
The case was finally dismissed.
Brennan McCarthy, a woman's lawyer in harassment case, said Ramos took information she confided to him in confidence, "and used it to destroy her life."
Ramos sent a letter to the woman's employer saying she was a bipolar drinker, which led to her release, the lawyer said.
"That was malice, he had a problem with this woman, I do not know what it was, but he did everything to destroy her life," said McCarthy.
Ramos posted veiled threats on social media and also turned his attention to McCarthy.  "This is a man who has prosecuted the lawyer for the stalking victim," said McCarthy
A Twitter account with Ramos' name and handle @ Eric HartleyFrnd is said to belong to Ramos, one said Law Enforcement Source
On Friday, the account was suspended
Years of Menacing Online Comments
Altomare said his department was investigating threatening online comments Ramos allegedly made against the newspaper In the same year, In a telephone conversation between a detective and the legal department of the newspaper, the "Capital Gazette" decided not to raise charges of apprehension to aggravate the situation, Altomare said.
An official of Anne Arundel wrote that he had not done so. I think Ramos was a threat to the paper's staff.
The police officer said the interactions between the suspect and the newspaper were only on Twitter and in civil court records.
The looming tweets and rumors include "Mention of Blood in the Water, Journalists Hell, Hitman (and) Open Season," wrote the officer.
Tom Marquardt, former editor and publisher of the Capital Gazette, told CNN on Friday that he was disappointed that the charges had not been filed.
"All I saw was a threat to my life and a threat to people who worked for me," said Marquardt. "However, they believed in their professional opinion that the evidence was not there."
Marquardt said that at the time, the newspaper's staff received a picture of Ramos with the instruction that if someone similar to him came through the door
Ramos gave no specific warning that he would attack the newspaper , the authorities said
suspects dismissed from his job
In 2014, Ramos was dismissed from his job as a help-desk specialist in the Bureau of Labor Statistics in Washington, according to court records.
Ramos sued for still owing him money and wrote in a letter that he was not reported to have committed any wrongdoing and that he was not given an explanation for his release.
His employer said the federal government requested that he be dismissed "based on safety concerns about the suitability arising from an investigation." The firm said it did not know the nature of the investigation.
Investigators said they found evidence at Ramos' apartment in Laurel, about a 30-minute drive from Annapolis.
They refused to provide details except to say that the results show "what we knew we would find we have a bad guy."
CNN's Jason Hanna, David Shortell, Madison Park and Betsy Klein have contributed to this report.