ANNAPOLIS, Md. — An attorney for the man accused of killing five Maryland newspaper employees last year told a court Monday that he will plead guilty but not criminally responsible by reason of insanity to the murders.

Attorney Katy O'Donnell said Jarrod Ramos intends to plead guilty to all 23 charges in the indictment, including five counts of first-degree murder, in connection with a shooting at the Capital Gazette newspaper in Annapolis in 2018.

O'Donnell's remarks came during a pretrial hearing in Annapolis.

Judge Laura Ripken still needs to accept the guilty pleas to make them official.

His plea means the case will skip the first phase of determining guilt and move to a second phase of determining whether he is criminally responsible.

The 39-year-old Ramos had originally pleaded not guilty and not criminally responsible. The latter term is Maryland's version of an insanity defense.

Employees of the newspaper who attended the hearing held hands as the attorney addressed the court.

Ramos' plea is the latest turn in his long history with the newspaper. Before the shooting, he had been accused of harassing the Capital Gazette's staff in connection with a defamation suit he filed against the newspaper in 2012, authorities have said. The suit was thrown out.

Authorities say Ramos stormed the newspaper office in June 2018 with a shotgun and killed John McNamara, Wendi Winters, Rebecca Smith, Gerald Fischman and Rob Hiaasen. It was one of the deadliest attacks on journalists in U.S. history.

Ramos' mental health had been a point of contention between defense attorneys and prosecutors as they prepared for his trial.