Jarrod W. Ramos, the man identified as the suspect in the shooting that killed five people at the Annapolis, Maryland, Capital Gazette, appears to have had a longstanding grudge against the newspaper over a 2011 column that reported his guilty plea to criminal harassment, according to court records.

Multiple senior law enforcement officials told NBC News that Ramos, 38, of Laurel in neighboring Prince George's County, was identified through the use of facial recognition software and that authorities were executing a search warrant at his home Thursday night.

"This was a targeted attack on the Capital Gazette," Deputy Anne Arundel Police Chief Bill Krampf said Thursday. "He entered the building with a shotgun, and he looked for his victims as he walked through the lower level."

Court records show that Ramos pleaded guilty in July 2011 to criminal harassment in Anne Arundel County, where the Capital Gazette is based. A 90-day jail sentence was suspended, and Ramos was placed on 18 months' supervised probation.

Five days later, the Capital Gazette published a column headlined "Jarrod wants to be your friend," profiling the woman who said she was the victim of Ramos' harassment. The article is no longer on the newspaper's website, but it was reprinted in full in the court documents.

In the column, the woman, whose name was withheld, claimed that Ramos tracked her down on Facebook and then harshly harassed her through email for as long as two years.

The column quoted her as saying that Ramos urged her to kill herself and that the bank where she worked put her on probation because of "an email from Ramos and a follow-up phone call in which he advised them to fire her."

The column said she was laid off a few months later and "believes, but can't prove, it was because of Ramos."

In July 2012, Ramos, representing himself, sued the Capital Gazette; Eric Hartley, a former reporter who wrote the column; and Thomas Marquardt, the newspaper's publisher at the time, in Prince George's County Circuit Court alleging defamation. He filed a longer complaint in October 2012, two months after the statute of limitations for the alleged defamation had expired, adding an allegation of invasion of privacy.

The circuit judge dismissed the complaint in 2013, saying: "There is nothing in those complaints that prove that anything that was published about you is, in fact, false. It all came from a public record. It was of the result of a criminal conviction. And it cannot give rise to a defamation suit."

Ramos appealed, and in September 2015, the appeals court upheld the dismissal, writing that Ramos "never alleges that any basic fact contained in the article about his guilty plea is actually false."

"The appellant was charged with a criminal act," the court wrote. "The appellant perpetrated a criminal act. The appellant plead guilty to having perpetrated a criminal act. The appellant was punished for his criminal act. ... He does not appear to have learned his lesson."

John Frenaye, the founder of Eye on Annapolis, a local news site, said Ramos trolled him from 2013 to 2015, repeatedly airing his gripes against the Capital Gazette. (Eye on Annapolis and the Capital Gazette are not affiliated.)

"Any time it's that kind of troll, I just kind of ignore that," said Frenaye, who told NBC News he doesn't remember responding to Ramos or ever having written about him.

"I remember looking at it and thinking, 'Do I have to worry about it?' and thinking, 'No, his bug is with the Capital and Eric.' He had nicknames for them, too" — like "Slob" instead of Bob — Frenaye said.

"It's all sort of flooding back," Frenaye said. "I think he thought he had an audience, but I don't remember even reporting on him at all."

Krampf, the deputy police chief, said "general threats" were made toward the Capital Gazette as recently as Thursday.

"We know that there were threats sent through social media by this person," he said, adding: "This person was prepared today to come in, this person was prepared to shoot people. His intent was to cause harm."