A 27-year-old man on Friday pleaded guilty to murder in the fatal shooting of an Indianapolis police officer, in a deal that spares him the death penalty.

Major Davis will be sentenced April 27 in the July 2014 slaying of Indianapolis Metropolitan Police Department officer Perry Renn. The plea agreement calls for Davis to serve life in prison without the possibility of parole.

"By this plea, the family, friends, and witnesses impacted by this violent act will avoid what would likely have been years of courtroom proceedings," Marion County Prosecutor Terry Curry said in a statement.

Renn, 51, and another officer were responding to reports of shots fired on the city's north side when they came across Davis in an alley. Davis and the officers exchanged gunfire. Prosecutors said Davis struck Renn with three rounds from an assault rifle. Davis was critically injured in the exchange.

His case was repeatedly delayed by his attempts to fire his attorneys and by questions about his mental competency. But a judge ruled in February that Davis was mentally competent to stand trial and jury selection was set for October.

His attorneys have not responded to messages left Friday seeking comment.

Renn's widow, Lynn Renn, said in a statement that "justice has been served."

"This is the conclusion that I wanted and that Perry would have wanted. The plea provides finality and allows me and others deeply impacted to avoid the possibility of a lengthy trial and appeals process," she wrote.