HARRISONBURG, Va. (AP) — A man who had been scheduled for trial in the shooting deaths of two popular police officers at a Virginia college in 2022 instead pleaded guilty and was sentenced to life in prison.

Alexander Campbell, 29, pleaded guilty Monday to two counts of first-degree murder in the deaths of Bridgewater College Officer John Painter and Campus Safety Officer J.J. Jefferson, news outlets reported. Campbell also pleaded guilty to two counts of using a firearm during a felony.

A judge in Rockingham County Circuit Court accepted the terms of a plea agreement and handed down two life sentences, plus six years in prison. A trial had been scheduled for April.

Painter, 55, and Jefferson, 48, were friends who were known on campus as the “dynamic duo.” Campbell was a student at the school from 2013 to 2017 and had competed on the cross-country team.

The shooting happened Feb. 1, 2022, when the officers were called to an area outside the college’s Memorial Hall on a report of a suspicious man on campus.

At a hearing later that year where a judge determined Campbell was mentally fit to stand trial, a student described seeing Painter and Jefferson confront Campbell, who then fired several shots. The judge also heard from an officer who arrested Campbell. The officer said Campbell appeared to be coherent and wanted to know the officers’ names so he could apologize to their families.

After Campbell entered his plea, Rockingham County prosecutor Marsha Garst presented the evidence she would have used in a trial, noting that Campbell had been living illegally in the basement of Memorial Hall for four days before the shooting. He had the revolver used to kill the two officers, two shotguns, an air rifle, and a lock-picking kit, she said.

Relatives of the two officers provided impact statements before Campbell was sentenced, sharing how their lives were affected by their deaths. The deal was reached in part to avoid putting the victims’ families through the pain of a lengthy trial, Garst said. They were consulted throughout the negotiation and agreed with the deal, she said.

Bridgewater is in Virginia’s Shenandoah Valley, about 180 miles southwest of Washington, D.C.