A man accused of suffocating a family of three during a violent rampage entered into a last-minute plea agreement Tuesday that will spare him the death penalty.

Ray Joseph Dandridge, whose trial was underway, admitted to the Jan. 6 killings of Percyell Tucker, 55, his wife, Mary Baskerville-Tucker, 47, and her daughter, Ashley Baskerville, 21. The victims' faces had been covered in duct tape and the parents' throats cut.

He was sentenced to life in prison. Several of the victims' friends and family members wept quietly after the plea agreement was announced.

Click here to visit FOXNews.com's Crime Center

Click here to visit FOXNews.com's Law Center

Prosecutor Michael Herring said he agreed to the plea partly because of inconsistencies in Dandridge's police confession.

"Am I satisfied it was the smart and right thing to do? Yes," Herring said. "Do I feel good about the outcome? No."

Defense attorney Cary Bowen said the defense was concerned Dandridge would receive a death sentence if he did not change his plea.

Dandridge, 29, was on trial for three capital counts: killing someone during a robbery, killing more than one person at a time and killing more than one person in a three-year period.

Prosecutors say Dandridge and his uncle, Ricky Jovan Gray, killed the family as part of a rampage that included the killing of a second Richmond family less than one week earlier.

One of the charges against Dandridge — killing more than one person in a three-year period — was modified to include the slayings of the second family. Prosecutor Learned Barry said that was done to assign Dandridge culpability in those murders as well, even though he did not appear to be the triggerman in that case.

Gray, also 29, was convicted last month of capital murder in the New Year's Day slayings of musician Bryan Harvey, 49, his wife, Kathryn, 39, and daughters Stella, 9, and Ruby, 4. The family had been bound, beaten with a hammer and stabbed, their throats cut and their bodies set ablaze. Gray told police Ashley Baskerville was an accomplice in the Harvey slayings.

The jury recommended Gray be sentenced to death. Formal sentencing is set for Oct. 23.

Herring said he considered the differences in the two sets of slayings when debating the plea agreement.

"This was a very different crime scene involving very different victims, most notably the absence of children," he said.

Dandridge and Gray, both ex-convicts, were arrested Jan. 7 in Philadelphia at the home of Dandridge's father. Gray was not charged in the Baskerville-Tucker slayings, and Barry said Dandridge would not be charged in the Harvey killings.

In a statement to Philadelphia police, Gray said he, Dandridge and Baskerville had plotted to rob Baskerville's mother and stepfather. Dandridge told police Gray had been dating Baskerville and had grown tired of her, so he decided to kill her.

Gray also confessed to the Nov. 5 killing of his 35-year-old wife, Treva Terrell Gray, in Washington, Pa. In his confession, Gray said he beat his wife to death in their bed with a piece of pipe while Dandridge held her down.